Chapter 5 Exercises

  1. There are 3 syntax errors in the following code. Fix it to work correctly without errors.

     
    1
    from turtle import *
    2
    space = screen()
    3
    alex = Turtle
    4
    alex.Forward(150)
    5

    (ch5ex1q)

  2. The code below is correct, but the lines are in the wrong order. Fix it so that it runs properly.

    7
     
    1
    alex = Turtle()
    2
    alex.forward(150)
    3
    from turtle import *
    4
    alex.left(90)
    5
    space = Screen()
    6
    alex.forward(75)
    7

    (ch5ex2q)

  3. The following program is missing things on lines 1, 2, and 3. Add the missing parts.

    5
     
    1
    from ??
    2
    space = ??
    3
    alex = ??
    4
    alex.forward(150)
    5

    (ch5ex3q)

  4. Rearrange the code so it draws a square.

    11
     
    1
    from turtle import *
    2
    franklin = Turtle()
    3
    space = Screen()
    4
    franklin.left(90)
    5
    franklin.forward(100)
    6
    franklin.forward(100)
    7
    franklin.left(90)
    8
    franklin.forward(100)
    9
    franklin.left(90)
    10
    franklin.forward(100)
    11

    (ch5ex4q)

  5. The following code has 3 syntax errors. Fix the errors so that the code runs.

    7
     
    1
    from turtle import *
    2
    space = Screen()
    3
    alex = turtle()
    4
    alex.Forward(150)
    5
    alex.turn(90)
    6
    alex.forward(75)
    7

    (ch5ex5q)

  6. Fix the 6 errors in the following code.

    9
     
    1
    from turtle import
    2
    space = Screen
    3
    john = turtle()
    4
    john.Forward(100)
    5
    john.Left(120)
    6
    john.forward(100)
    7
    john.left(120)
    8
    john.Forward(100)
    9

    (ch5ex6q)

  7. The following code draws two lines of a rectangle. Add code to finish drawing the rectangle.

    7
     
    1
    from turtle import *
    2
    space = Screen()
    3
    alex = Turtle()
    4
    alex.forward(150)
    5
    alex.left(90)
    6
    alex.forward(75)
    7

    (ch5ex7q)

  8. You need to fix or add 4 things so that the code runs.

    8
     
    1
    space = Screen()
    2
    hi = Turtle()
    3
    hi.color(red)
    4
    hi.Forward("50")
    5
    hi.right(90)
    6
    hi.color("BLUE")
    7
    hi.forward(50)
    8

    (ch5ex8q)

  9. The following code is missing 3 lines that do the required set-up. Add them so that the code runs.

    4
     
    1
    alex.forward(150)
    2
    alex.left(90)
    3
    alex.forward(75)
    4

    (ch5ex9q)

  10. Finish the code so that it draws an equilateral triangle.

    5
     
    1
    from turtle import *
    2
    space = Screen()
    3
    alex = Turtle()
    4
    alex.forward(150)
    5

    (ch5ex10q)

  11. Create a drawing that includes penup, pendown, and pensize.

    3
     
    1
    2
    3

    (ch5ex11q)

  12. Fix the 5 errors.

    5
     
    1
    From turtle Import *
    2
    space = screen()
    3
    bob = turtle
    4
    Bob.forward("100")
    5

    (ch5ex12q)

  13. Create a drawing with at least 3 colors and using at least 3 turtles.

    3
     
    1
    2
    3

    (ch5ex13q)

  14. Fix the errors.

    8
     
    1
    from turtle import *
    2
    jack = Screen()
    3
    jill = Turtle()
    4
    jill.sizepen(10)
    5
    jill.forward(10)
    6
    jack.sizepen(15)
    7
    jack.forward(10)
    8

    (ch5ex14q)

  15. Write code below to draw a diamond shape.

    3
     
    1
    2
    3

    (ch5ex15q)

  16. Write code that spells CS in block letters (it will look more like C5).

    3
     
    1
    2
    3

    (ch5ex16q)

  17. Write code below to draw a star like this picture.

    ../_images/star.png
    3
     
    1
    2
    3

    (ch5ex17q)

  18. Write code to draw a “V” starting from the center with each side a different color and only turning the turtle twice and no using penup or pendown.

    3
     
    1
    2
    3

    (ch5ex18q)

  19. Write code below to draw at least one of your initials in block style.

    3
     
    1
    2
    3

    (ch5ex19q)

  20. Use 4 turtles and 4 colors to draw a big plus sign with each segment of the plus sign being a different color.

    3
     
    1
    2
    3

    (ch5ex20q)

Next Section - Chapter 6 - Computers can Name Anything