Module 2 · Line Tracking
Lesson 8 · Introduction to Classes — Knowledge ChecksAnswer key
What's the difference between a class and an object?
One class (blueprint) can produce many objects (instances). LineSensor is the blueprint; the sensor you create from it is an object.
When does the __init__ method run?
__init__ is the constructor — Python calls it automatically the moment you build a new object with LineSensor().
You have `sensor = LineSensor()`. How do you call its get_error method?
You never pass self yourself — Python supplies it automatically. Just sensor.get_error().
Write is_on_line() to return True when AT LEAST ONE sensor is on the line. Which body is correct?
'At least one' means or, and each reading needs self. — self.get_left() > self.threshold or self.get_right() > self.threshold.