Skip to main content
Module 1 · Learning to Drive

Lesson 1-9 · Variables & Expressions — Knowledge ChecksAnswer key

Correct answers are marked and the explanation follows each question.

  1. What is the difference between = in math and = in Python?

    1. A.There is no difference
    2. B.In Python it is an instruction: work out the right side, then store the result in the named memory on the left✓
    3. C.In Python it means "is approximately equal to"
    4. D.In Python it only works with whole numbers

    Math's = states that two things are equal. Python's = does something: it works out the right-hand side and stores that result in the variable named on the left.

  2. After these three lines, what is total?

    total = 10
    total = total + 5
    total = total + 5
    1. A.10
    2. B.15
    3. C.20✓
    4. D.It causes an error because total is used to define itself

    Each line reads what is currently in total, works out the right side with it, and stores the result back: 10, then 10+5 = 15, then 15+5 = 20.

  3. In the line reflectance = Reflectance.get_default_reflectance() what is the difference between the two spellings?

    1. A.Nothing — Python ignores capital letters
    2. B.Capitalized Reflectance is the class; lowercase reflectance is the variable holding the sensor you will use✓
    3. C.The capitalized one is a typo that Python fixes
    4. D.Capitalized names are for numbers, lowercase for text

    Python is case-sensitive, and the convention is Capitalized for classes, lowercase snake_case for your own variables. Both names are needed and they mean different things.

  4. What is the value of 10 + 4 * 2 ?

    1. A.28
    2. B.18✓
    3. C.80
    4. D.16

    Multiplication goes before addition: 4 * 2 = 8 first, then 10 + 8 = 18. To get 28 you would need parentheses: (10 + 4) * 2.

  5. Your white reading is 0.2 and your black reading is 0.8, and you want the midpoint (0.5). Which line gives it?

    1. A.threshold = white + black / 2
    2. B.threshold = (white + black) / 2✓
    3. C.threshold = white + black // 2
    4. D.Both of the first two work

    Without parentheses, only black is divided: 0.2 + 0.4 = 0.6 — not the midpoint. The parentheses force the addition first: (0.2 + 0.8) / 2 = 0.5.