Data Types and Variables Flashcards
7 cards from real Python practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 7 Data Types and Variables flashcards as text
What is the result of `type(3.0)` in Python?
Answer:
3.0 is a floating-point literal, so its type is `float`.
Which statement correctly creates a complex number in Python?
Answer: z = complex(2, 3)
`complex(2, 3)` creates the complex number 2+3j; Python uses `j` not `i` in literals.
What does `bool` inherit from in Python's type hierarchy?
Answer: int
`bool` is a subclass of `int`, so `True == 1` and `False == 0`.
What is the output of `print(type(None))`?
Answer:
Python's `None` is the sole instance of the built-in `NoneType` class.
Which of the following variable names is INVALID in Python?
Answer: 2count
Variable names cannot begin with a digit; `2count` is a syntax error.
What is the value of `int('0b1010', 0)` in Python?
Answer: 10
Passing base `0` tells `int()` to auto-detect the base from the prefix; `0b1010` is binary 10.
After `x = 5`, which operation changes `x` to a float WITHOUT reassigning explicitly?
Answer: x /= 1
True division `/=` always returns a float, so `x /= 1` makes x equal 5.0.