Python Beginner Quiz
Types, lists, dicts, loops and functions — checked by reading real code rather than reciting definitions.
Start the quizSample questions from this quiz
A preview of the style and depth. Try each one, then reveal the answer — or skip straight to the timed quiz.
1. What does this print?
x = 10
y = 3
print(x / y, x // y, x % y)- 3.33 3.33 1
- 3 3 1
- 3.3333333333333335 3 1
- 3.3333333333333335 3.0 1
Show answer
Answer: 3.3333333333333335 3 1. `/` always produces a float in Python 3, even when the division is exact. `//` is floor division and `%` gives the remainder. In Python 2 `/` truncated for integers, which is a classic source of migration bugs.
2. What does this print?
items = ['a', 'b', 'c']
print(items[0], items[-1], items[1:3])- a a ['a', 'b']
- a c ['b']
- b c ['b', 'c']
- a c ['b', 'c']
Show answer
Answer: a c ['b', 'c']. Indexing starts at 0, and negative indices count from the end so `-1` is the last item. Slices are end-exclusive: `[1:3]` takes indices 1 and 2. Slicing never raises IndexError — out-of-range bounds are simply clamped.
3. This raises TypeError. Which line is wrong?
1 age = input('Age: ')
2 if age > 18:
3 print('adult')- Line 2 — input returns a string, which cannot be compared to an int
- Line 1 — input needs a type argument
- Line 3 — print needs parentheses
- Line 2 — the comparison should use ==
Show answer
Answer: Line 2 — input returns a string, which cannot be compared to an int. `input()` always returns a string, and Python refuses to compare str with int rather than guessing. Convert first: `age = int(input('Age: '))`. Wrap that in try/except ValueError if the user might type something non-numeric.
Frequently asked questions
How many questions are in this Python quiz?+
30 questions, with a 30-minute time limit. Every question includes a written explanation of the correct answer.
Is this Python quiz free?+
Yes. Every quiz on CodexQuizz is free and needs no account. You only enter a name if you choose to post your score to the leaderboard.
What level is the beginner quiz aimed at?+
Types, lists, dicts, loops and functions — checked by reading real code rather than reciting definitions.
Can I use this to prepare for a Python interview?+
Yes. The questions cover the topics that come up in Python technical screens, and the explanations are written so that a wrong answer still teaches you the underlying concept.
Ready to test your Python?
30 questions, 30 minutes. Free, no sign-up.
Start now