Skip to content

This textbook is in beta – content is actively being refined. Report issues or suggestions

03.02 Standard Data Types - Quiz

Check your understanding

  1. Which Python data type would be most appropriate for storing a student’s age?

    • str (string)
    • int (integer) { data-correct }
    • float
    • bool (boolean)
  2. What is the result of this Python code: bool("")?

    • True
    • False { data-correct }
    • Error
    • None
  3. Which data type should you use to store a product price like $19.99?

    • int (integer)
    • str (string)
    • float { data-correct }
    • bool (boolean)
  4. What happens when you convert the float 3.9 to an integer using int(3.9)?

    • 3 { data-correct }
    • 4
    • 3.9
    • Error
  5. Which of these would be stored as a string (str) data type?

    • A person’s age: 17
    • A test score: 85.5
    • A postal code: “2000” { data-correct }
    • Whether someone passed: True
  6. What Python module do you need to import to work with dates?

    • time
    • calendar
    • datetime { data-correct }
    • date
  7. Which logical operation would you use to check if a student is both enrolled AND passing?

    • or
    • and { data-correct }
    • not
    • ==
  8. What is the correct way to create a date object for January 15, 2006?

    • date(“2006-01-15”)
    • date(2006, 1, 15) { data-correct }
    • date(15, 1, 2006)
    • date.new(2006, 1, 15)
  9. Which conversion will cause an error?

    • int(“42”)
    • float(“3.14”)
    • int(“3.14”) { data-correct }
    • str(42)
  10. For a student record system, which data type combination is most appropriate?

    • name: str, age: str, grade: str, enrolled: str
    • name: int, age: int, grade: int, enrolled: int
    • name: str, age: int, grade: float, enrolled: bool { data-correct }
    • name: bool, age: float, grade: str, enrolled: int
  11. What does isinstance(42, int) return?

    • True { data-correct }
    • False
    • 42
    • int
  12. Which data type would be best for storing whether a user is currently logged in?

    • str (“yes” or “no”)
    • int (1 or 0)
    • bool (True or False) { data-correct }
    • float (1.0 or 0.0)