Quiz: Python Basics
Test your knowledge of Python variables, data types, operators, and strings with 10 multiple-choice questions.
Related chapter: Python Basics
Q1. What is the output of print(type(3.14))?
- A)
<class 'int'> - B)
<class 'float'>✓ - C)
<class 'double'> - D)
<class 'number'>
Python only has
intandfloatfor numeric types — no separatedouble.
Q2. What does 10 // 3 evaluate to?
- A)
3.333 - B)
3✓ - C)
1 - D)
3.0
//is floor division — it returns an integer result.
Q3. Which creates a valid f-string?
- A)
f("Hello {name}") - B)
f"Hello {name}"✓ - C)
"Hello {name}".format() - D)
format("Hello {name}")
Q4. What is the result of "hello"[::-1]?
- A)
"hello" - B)
"olleh"✓ - C)
"hell" - D) Error
[::-1]reverses any sequence.
Q5. Which values are falsy in Python?
- A)
0,"",[],None,False✓ - B)
0,"0",[],None - C) Only
FalseandNone - D)
0,False,-1
"0"is a non-empty string — it’s truthy.
Q6. What does list("abc") return?
- A)
["abc"] - B)
['a', 'b', 'c']✓ - C)
('a', 'b', 'c') - D) Error
Q7. How do you convert the string "42" to an integer?
- A)
str(42) - B)
integer("42") - C)
int("42")✓ - D)
"42".toInt()
Q8. What is the output of print(2 ** 3 ** 2)?
- A)
64 - B)
512✓ - C)
36 - D)
81
Exponentiation is right-associative:
2 ** (3 ** 2)=2 ** 9= 512.
Q9. Which is a valid variable name?
- A)
2name - B)
my-var - C)
_private✓ - D)
class
Variable names can’t start with digits or contain hyphens.
classis a reserved keyword.
Q10. What does "a" + "b" * 3 evaluate to?
- A)
"ababab" - B)
"abbb"✓ - C)
"aaabbb" - D) Error
Multiplication has higher precedence:
"a" + ("b" * 3).
Scoring: 8–10 = ready for Control Flow. 5–7 = re-read Basics. Below 5 = start with First Program.
Next: Control Flow Quiz