Chapter 10 ExercisesΒΆ
Fix 4 syntax errors in the code below to correctly draw a square
The code currently draws a square. Change it so that it draws a triangle.
Fix the code below to draw a rectangle. You will need to fix the indention on 3 lines.
Fix the errors in the code so that it draws an octagon.
Fill in values for
x
on line 5 andy
on line 7 to allow the code below to correctly draw a pentagon.Complete the code on lines 5 and 7 to draw a hexagon.
Finish the code on lines 1, 2, 3, 6 and 8 below to correctly draw a triangle.
Finish the code to draw a 15 sided figure with each side having a length of 40.
Fix the indention in the code below to correctly draw 20 pentagons.
The procedure below draws a square. Write code that uses the procedure to draw two squares connected by a line 50 units in length.
Fix the following code below to draw a circle of turtles using the
stamp
procedure. You will need to change 3 lines.Complete the code where the
x's
are so that the code draws 20 triangles.Rewrite the following code to create a procedure to draw a square with a turtle. Pass the turtle and the size of the square as input (parameters) to the procedure.
Currently, the code has a turtle drawing a straight line. Add 2 lines of code (1 before the loop and 1 in the loop) to make the turtle stamp in the line.
Rewrite the following code to create a procedure to draw a rectangle with a turtle. Pass the turtle and the length and width of the rectangle as parameters to the procedure.
Complete the code so that the turtle stamps a square pattern 20 times (it should look like a circle enclosing a couple of circles if you use a turn angle of 18)
Create a procedure to draw 4 turtles at the 4 corners of a square using the
stamp
procedure.Create a procedure that takes in a turtle and integer parameter. The procedure should stamp a turtle shape into a circle in 20 steps with the forward number being equal to the parameter.
Write a procedure that takes a turtle and a number of sides as parameters and draws a polygon with that number of sides.
Write a procedure that takes a turtle, an int for the number of sides for a polygon, and an int for the number of times to draw that polygon. The procedure should draw that polygon that number of times in a circular path.