Choose the correct option with respect to python
A. Both tuples and lists are immutable
B. Tuples are immutable while lists are mutable
C. Both tuples an lists are mutable
D. Tuples are mutable while lists are immutable
Correct Answer :
B). Tuples are immutable while lists are mutable
Preparing for Python exams or certification tests? Multiple choice
questions (MCQs) are a proven way to test your core Python knowledge. Below are
15 essential Python MCQs with detailed explanations to help you master key
concepts and avoid common pitfalls.
Top 15 Python MCQs with
Explanations
- What
is the output of print(type(5))?
a) <class ‘int’>
b) <class ‘number’>
c) <class ‘float’>
d) <class ‘digit’>Correct:
a
Explanation: 5 is an integer literal. Python’s type() function
returns <class ‘int’> for integers. - Which
is valid for single line comments?
a) // Comment
b) /* Comment */
c) # Comment
d) <! Comment >Correct:
c
Explanation: Python uses # for single line
comments. // is for floor division, not comments. - What
does “hello”[1:4] return?
a) “hel”
b) “ell”
c) “llo”
d) “lo”Correct:
b
Explanation: Slicing includes start index (1=’e’) and
stops before end index (4=’o’), giving ‘ell’. - Which
is immutable?
a) List
b) Dictionary
c) Tuple
d) SetCorrect:
c
Explanation: Tuples are immutable (can’t modify after
creation). Lists, dicts, and sets are mutable. - What
is print(3 * ‘ab’)?
a) ababab
b) 3ab
c) ab3
d) ErrorCorrect:
a
Explanation: Multiplying a string repeats it: ‘ab’ repeated
3 times = ‘ababab’.
Common Python
Misconceptions (MCQ Edition)
- Which
will cause a SyntaxError?
a) print(“Hello”)
b) x = 5
c) if 5 > 2: print(“Five”)
d) for = 5Correct:
d
Explanation: for is a reserved keyword. Using it as a
variable name triggers SyntaxError. - What
is the output of bool(“0”)?
a) False
b) True
c) 0
d) ErrorCorrect:
b
Explanation: Non empty strings are True in
Python. “0” has length 1 → True. - Which
correctly opens a file for reading?
a) open(“file.txt”, “r”)
b) open(“file.txt”, “read”)
c) open(“file.txt”, “w”)
d) open(“file.txt”)Correct:
a & d
Explanation: “r” is the explicit read mode,
but open() defaults to read mode if omitted.
Tricky Function &
OOP Scenarios
- What
does this return?
python
def func(x, y=[]):
y.append(x)
return y
print(func(1), func(2))
a) [1] [2]
b) [1] [1,2]
c) [1] [2]
d) [1] [1] Correct: b
Explanation: Mutable default arguments (y=[]) persist between calls
→ both modify same list.
- What
is method overriding?
a) Changing method names
b) Redefining a parent method in child class
c) Deleting inherited methods
d) Hiding private methodsCorrect:
b
Explanation: Overriding = Child class provides specific
implementation for inherited method.
Python MCQ Cheat Sheet:
Quick Reference
Concept |
Key Rule |
Example Trick |
Slicing |
start:stop:step (stop excluded) |
“Python”[1:4] → “yth” |
Mutability |
Lists/dicts/sets mutable; tuples/strings/frozensets |
t = (1,); t[0]=2 → Error |
Truthiness |
False: 0, “”, None, [], {} |
bool([]) → False |
Scope |
global keyword modifies global vars |
Without global, assignment creates local |
is vs == |
is checks identity (memory address); == checks |
[] is [] → False |
Pro Tips for Python MCQ
Tests
- Watch
for off by one errors in loops/slicing (e.g., range(5) =
0 4) - Remember
operator precedence: ** > % > // > + (use () when
unsure) - Immutable
objects aren’t copied in function args (changes create new
objects) - print(0.1
+ 0.2 == 0.3) → False (floating point precision quirk)
Final Answer Key for Sample
MCQs:
Q# |
Answer |
Q# |
Answer |
1 |
a |
6 |
d |
2 |
c |
7 |
b |
3 |
b |
8 |
a, d |
4 |
c |
9 |
b |
5 |
a |
10 |
b |