When completing your code challenges keep in mind the four characteristics of quality code…
- Functional – Accomplishes it’s task every time.
- Readable – Easy for a human to read and edit.
- Efficient – Executes quickly without unnecessary steps.
- Short – Uses the fewest lines of code.
Or put another way…
- Does it work? Your code should meet all of the requirements and work in every situation.
- Is it understandable? Your code should be easy for a human to read and understand.
- Is it fast? You code should execute and finish as quickly as possible.
- Is it short? Your code should be as few line of code as possible.
Submit Your Turtle Challenges here. Please make sure your challenge meets all of the requirements before submitting. Also please make sure your app is titled “Turtle #__” to make it extra clear which challenge you have completed.
- Draw Square – Draw a single square in front of and to the right of the turtle (image).
- Only use moveForward(), turnLeft()
- No loops, No functions, No parameters.
- Draw Square – Draw a single square in front of and to the right of the turtle (image)
- Only use moveForward(), turnLeft()
- No functions, No parameters.
- You can use “For Loops” Please click here to learn more
- Draw Square – Draw a single square in front of and to the right of the turtle (image)
- Only use moveForward(), turnLeft(), move(), penUp(), penDown()
- No loops, No functions
- You can use “parameters” Please click here to learn more.
- Draw Square – Draw a single square in front of and to the right of the turtle (image)
- Only use moveForward(), turnLeft()
- No loops, No parameters
- You can use “functions” Please click here to learn more.
- 2×2 Grid – Draw a two by two grid in front of and to the right of the turtle (image).
- Only use moveForward(), turnLeft()
- No loops, No functions, No parameters.
- 2×2 Grid – Draw a two by two grid in front of and to the right of the turtle (image).
- Only use move(), penUp(), penDown()
- No loops, No functions.
- You can use “parameters”
- Must be less than 15 lines of code.
- 2×2 Grid – Draw a two by two grid in front of and to the right of the turtle (image).
- Only use moveForward(), turnLeft()
- No loops, No parameters.
- You can use “functions“
- Must be less than 30 lines of code
- 2×2 Grid – Draw a two by two grid in front of and to the right of the turtle (image).
- Only use moveForward(), turnLeft()
- No functions, No parameters.
- You can use “For Loops” (You can put loops inside of other loops, just make sure each loop uses different letters: i, j, k, etc)
- Must be less than than 20 lines of code.
- 3×3 Grid – Draw a three by three grid in front of and to the right of the turtle.
- Only use moveForward(), turnLeft()
- No functions, No loops, No parameters.
- Use less than 55 lines of code (Extra credit if less than 45 lines)
- 3×3 Grid – Draw a three by three grid in front of and to the right of the turtle.
- Only use move(), penUp(), penDown()
- No loops, No functions.
- You can use “parameters” (example: move(50,25) )
- Use less than 25 lines of code (Extra credit if less than 15 lines)
- 3×3 Grid – Draw a three by three grid in front of and to the right of the turtle (image).
- Only use moveForward(), turnLeft()
- No loops, No parameters
- You can use “Functions“
- Use less than 35 lines of code (Extra extra credit if less than 20 lines of code).
- 3×3 Grid – Draw a three by three grid in front of and to the right of the turtle.
- Only use moveForward(), turnLeft()
- No functions, No parameters.
- You can use “For Loops”
- Use less than 35 lines of code (Extra credit if less than 20 lines)
- Draw A Polygon – Write a function drawRegularPolygon(numberOfSides, sideLength) that draws a regular polygon with a given number of sides and a given side length.
- The polygon should be drawn in front of, and to the right of, the turtle.
- The turtle should end in the position and orientation it started at before the function was called.
- The bottom line segment of the polygon should be perpendicular to the starting position of the turtle.
- The numberOfSides variable will never be less than three since there is no polygon with less than three sides.
- View an example of a custom function with parameters.
- View and Remix this code to be extra clear on what this challenge is asking.
- Draw Square Grid – Write a function drawSquareGrid(unitSize,rows,columns) that draws a grid of squares in front of and to the right of the turtle where each little square has a side length of “unitSize” and the grid is “rows” units tall and “columns” units wide. The turtle should end at the position and orientation where it started. View Example Code.
- You may use functions, loops, parameters, and the commands moveForward(), turnLeft(), and turnRight();
- Some example code that we talked about in class that illustrates using parameters in your function. You might also consider looking at your Turtle Challenge#13 as an example.
- Draw a triangle inside a rectangle – Write a function drawTriangleInRectangle(width, height) that draws a rectangle with a base length of “width” and a height of “height”. This should all be draw in front of, and to the right of, the turtle. The turtle should end where is began. You may use whatever commands or functions that you would like. View Example (click view code).