03.02 Standard Data Types - Quiz¶
Check your understanding
-
Which Python data type would be most appropriate for storing a student’s age?
- str (string)
- int (integer) { data-correct }
- float
- bool (boolean)
-
What is the result of this Python code:
bool("")?- True
- False { data-correct }
- Error
- None
-
Which data type should you use to store a product price like $19.99?
- int (integer)
- str (string)
- float { data-correct }
- bool (boolean)
-
What happens when you convert the float 3.9 to an integer using
int(3.9)?- 3 { data-correct }
- 4
- 3.9
- Error
-
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
-
What Python module do you need to import to work with dates?
- time
- calendar
- datetime { data-correct }
- date
-
Which logical operation would you use to check if a student is both enrolled AND passing?
- or
- and { data-correct }
- not
- ==
-
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)
-
Which conversion will cause an error?
- int(“42”)
- float(“3.14”)
- int(“3.14”) { data-correct }
- str(42)
-
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
-
What does
isinstance(42, int)return?- True { data-correct }
- False
- 42
- int
-
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)