Before you keep reading...
Runestone Academy can only continue if we get support from individuals like you. As a student you are well aware of the high cost of textbooks. Our mission is to provide great books to you for free, but we ask that you consider a $10 donation, more if you can or less if $10 is a burden.
Before you keep reading...
Making great stuff takes time and $$. If you appreciate the book you are reading now and want to keep quality materials free for other students please consider a donation to Runestone Academy. We ask that you consider a $10 donation, but if you can give more thats great, if $10 is too much for your budget we would be happy with whatever you can afford as a show of support.
10.8. 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
xon line 5 and
yon 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
stampprocedure. You will need to change 3 lines.
Complete the code where the
x'sare 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
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.