← All public quizzes
Start the quiz (as a guest or with an account)
Python — Basics: Syntax, Types & Variables
by Jude · 23/05/2026 · 114 views · shares
Get started with Python: variables, primitives, operators, type conversion, syntax. 20 questions.
20
Questions
🇬🇧 English
Language
Easy
Difficulty
Questions in this quiz
-
1. What does this print?
x = 7 y = 2 print(x // y, x % y)- 3 1
- 3.5 1
- 3 0
- 4 -1
-
2. Which is an invalid Python identifier?
- _var
- var1
- 1var
- var_1
-
3. What does
type(3 / 2)return in Python 3?- <class 'int'>
- <class 'float'>
- <class 'complex'>
- <class 'number'>
-
4. What is printed?
a = "3" b = 4 print(a * b)- 12
- 7
- 3333
- TypeError
-
5. Which literal has type
bool?- "True"
- 1
- True
- [True]
-
6. What does
bool(0) or bool('')return?- True
- False
- None
- TypeError
-
7. Which symbol starts a single-line comment?
- //
- #
- --
- /*
-
8. What does this print?
print(2 ** 3 ** 2)- 64
- 512
- 12
- SyntaxError
-
9. How do you convert
"42"to int?- str(42)
- int("42")
- float("42")
- eval("42.0")
-
10. What does
len("café")return in Python 3?- 3
- 4
- 5
- TypeError
-
11. What is the value?
x = 0.1 + 0.2 print(x == 0.3)- True
- False
- Rounding error raised
- None
-
12. What does this print?
a = b = [1, 2] a += [3] print(b)- [1, 2]
- [1, 2, 3]
- [3]
- Error
-
13. What does this print in CPython?
x = 256; y = 256 a = 257; b = 257 print(x is y, a is b)- True True
- False False
- True False
- False True
-
14. What does the walrus do here?
if (n := len(data)) > 10: ...- Syntax error
- Assigns
n = len(data)and uses it in the test - Compares
ntolen(data) - Defines
nas global
-
15. What is
s?s = f"{42:08.3f}" print(s)- " 42.000"
- "0042.000"
- "42.00000"
- "00042.000"
-
16. Which statement about type annotations in CPython is true?
- They are enforced at runtime
- They are advisory and not enforced at runtime by CPython (apart from
__annotations__) - They cost a lot of memory
- They replace
isinstance
-
17. What does this print?
print("ab" * 3 + "-" + str(3 * 'ab'))- ababab-ababab
- ababab-3ab
- ababab-(ab)(ab)(ab)
- TypeError
-
18. What does this print?
print("-".join(str(i) for i in range(4)))- 0123
- 0-1-2-3
- [0,1,2,3]
- 0,1,2,3
-
19. What does
x, *rest, y = [1, 2, 3, 4, 5]bind?- x=1, rest=[2, 3, 4], y=5
- x=1, rest=2, y=[3, 4, 5]
- x=[1, 2], rest=[3], y=[4, 5]
- SyntaxError
-
20. What does this print in Python 3.10+?
def kind(x): match x: case 0: return "zero" case int() if x > 0: return "pos" case int(): return "neg" case _: return "other" print(kind(-3), kind(0), kind(2.5))- neg zero other
- neg zero pos
- other zero other
- SyntaxError