Skip to main content
Module 1 · Learning to Drive

Lesson 1-8 · Hello, Python — Knowledge Checks

Name Date
  1. What's the main advantage of a general-purpose language like Python over Blockly?

    1. A.Python programs always run faster
    2. B.It isn't limited to the blocks someone built, and it opens up libraries other people have already written and tested
    3. C.Python makes it impossible to write a program with mistakes in it
    4. D.Blockly cannot do loops or functions

    Answer Why?

  2. A program starts with "from XRPLib.rangefinder import Rangefinder" and then calls rangefinder.distance(). It fails with a NameError. What was skipped?

    1. A.Step 2 — no instance was made, so the name rangefinder means nothing yet
    2. B.Step 1 — the import line is wrong
    3. C.The program needs to import Rangefinder twice
    4. D.Nothing — distance() only works in Blockly

    Answer Why?

  3. Where do the three steps actually go in a real program?

    1. A.Steps 1 and 2 go near the top and run once; step 3 goes wherever the program needs that device, as often as it likes
    2. B.All three must be written together, in that order, every time
    3. C.Step 2 has to be repeated before each use of the device
    4. D.They can go in any order as long as all three are present

    Answer Why?

  4. Which line is written correctly?

    1. A.Print("Driving...")
    2. B.print "Driving..."
    3. C.print("Driving...")
    4. D.print(Driving...)

    Answer Why?

  5. What do the parentheses in board.wait_for_button() do?

    1. A.They tell Python to call the function — and anything inside them is an argument passed to it
    2. B.They are decoration; Python ignores them
    3. C.They mean the function returns nothing
    4. D.They are only needed when there is something inside them

    Answer Why?

  6. Why does drivetrain.straight(-30) drive the robot backward?

    1. A.Negative numbers reverse the direction — same as a negative cm in the Straight block
    2. B.It drives forward 30 cm, then stops
    3. C.It turns instead of driving
    4. D.It causes an error

    Answer Why?

  7. Find the bug in the code above.

    1. A.straight should be capitalized
    2. B.Print should be lowercase: print
    3. C.The distances should be positive
    4. D.There is no bug

    Answer Why?