Skip to main content
Module 2 · Line Tracking

Lesson 8 · Introduction to Classes — Knowledge Checks

Name Date
  1. What's the difference between a class and an object?

    1. A.They are two words for the same thing
    2. B.A class is the blueprint; an object is a specific thing built from it
    3. C.A class is smaller than an object
    4. D.An object is only for sensors

    Answer Why?

  2. When does the __init__ method run?

    1. A.When you import the file
    2. B.When you create an object with LineSensor()
    3. C.Every time you call any method
    4. D.At the end of the program

    Answer Why?

  3. You have `sensor = LineSensor()`. How do you call its get_error method?

    1. A.sensor.get_error(self)
    2. B.sensor.get_error()
    3. C.get_error(sensor)
    4. D.LineSensor.get_error()

    Answer Why?

  4. Write is_on_line() to return True when AT LEAST ONE sensor is on the line. Which body is correct?

    1. A.return self.get_left() > self.threshold or self.get_right() > self.threshold
    2. B.return self.get_left() > self.threshold and self.get_right() > self.threshold
    3. C.return get_left() or get_right()
    4. D.return self.threshold

    Answer Why?