Why can get_left() use reflectance when it was never passed in as a parameter?
- A.Python passes the first variable in the file automatically
- B.reflectance is a global variable — created outside every function, so every function below it can read it
- C.get_left() creates its own reflectance each call
- D.It cannot; this is a bug
Answer Why?
Which condition detects an intersection (both sensors on the line)?
- A.left > 0.5 or right > 0.5
- B.left > 0.5 and right > 0.5
- C.left > 0.5
- D.not (left > 0.5)
Answer Why?
Both sensors read 0.2 with THRESHOLD = 0.5. What do is_at_cross() and is_either_on_line() return?
- A.True and True
- B.False and False — neither reading is above the threshold, so neither the and nor the or is satisfied
- C.False and True
- D.True and False
Answer Why?
Why does get_error() call get_left() instead of reflectance.get_left()?
- A.reflectance.get_left() is slower
- B.So only one function knows how the hardware is read — if the sensor changes, you fix get_left() and everything else keeps working
- C.Functions cannot use global variables twice
- D.It makes no difference either way
Answer Why?
Why does set_threshold() need the global keyword when is_at_cross() does not?
- A.Because set_threshold takes a parameter
- B.is_at_cross() only reads THRESHOLD; set_threshold() assigns to it, and without global the assignment makes a throwaway local variable instead
- C.Every function that mentions THRESHOLD needs global
- D.Because THRESHOLD is in capitals
Answer Why?