Skip to main content
Module 1 · Learning to Drive

Lesson 9 · Python Loops — Knowledge Checks

Name Date
  1. What numbers does range(4) produce?

    1. A.1, 2, 3, 4
    2. B.0, 1, 2, 3
    3. C.0, 1, 2, 3, 4
    4. D.4, 3, 2, 1

    Answer Why?

  2. In the code above, how many times does print("Square complete!") run?

    1. A.Four times — once per loop
    2. B.Once, after the loop finishes
    3. C.Never
    4. D.It causes an error

    Answer Why?

  3. You want a loop to run 6 times to draw a hexagon. What goes in the range?

    1. A.range(5)
    2. B.range(6)
    3. C.range(7)
    4. D.range(60)

    Answer Why?

  4. In the nested program above, how many times does drivetrain.straight() run in total?

    1. A.Four times — once per square
    2. B.Sixteen times — four sides in each of four squares
    3. C.Eight times
    4. D.Once, because it is inside two loops

    Answer Why?

  5. What happens if you indent the size line twice, so it lines up with the drivetrain lines?

    1. A.Nothing changes
    2. B.The program will not run at all
    3. C.Every square comes out the same size
    4. D.The robot draws only one square

    Answer Why?