Python Quiz: 5 Multiple-Choice Questions
🎯 Difficulty level
Beginner → Lower Intermediate
These questions test:
-
core Python data types
-
references & mutability
-
default arguments
-
basic exception handling
-
syntax understanding
👉 Ideal for:
-
beginners who finished the basics
-
early-intermediate learners
-
screening fundamental Python knowledge
1) What is the output of the following code?
print(type([]) is list)
TrueFalselist- It raises an error
Show answer
✅ Correct: A —
type([]) is list, so the identity check is True.2) What will this print?
x = [1, 2, 3]
y = x
y.append(4)
print(x)
[1, 2, 3][1, 2, 3, 4][4, 1, 2, 3]- It raises an error
Show answer
✅ Correct: B —
y references the same list object as x.3) Which statement correctly creates a set with one element?
{}{1}set(1)[1]
Show answer
✅ Correct: B —
{1} is a set with one element. {} is an empty dict.4) What does this code output?
def f(a, b=10):
return a + b
print(f(5))
51015- It raises an error
Show answer
✅ Correct: C —
b defaults to 10, so 5 + 10 = 15.5) Which of the following is the correct way to handle an exception?
catch Exception:try: ... except: ...try: ... catch: ...if error: ...
Show answer
✅ Correct: B — Python uses
try / except to handle exceptions. Views: 1
Comments are closed.