ALL DATA ANALYSIS EDUCATION PYTHON

Python Quiz: 5 Multiple-Choice Questions

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)
  1. True
  2. False
  3. list
  4. 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. [1, 2, 3]
  2. [1, 2, 3, 4]
  3. [4, 1, 2, 3]
  4. 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. {}
  2. {1}
  3. set(1)
  4. [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))
  1. 5
  2. 10
  3. 15
  4. 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?
  1. catch Exception:
  2. try: ... except: ...
  3. try: ... catch: ...
  4. if error: ...
Show answer
✅ Correct: B — Python uses try / except to handle exceptions.
Views: 1

Comments are closed.

Pin It