🐍 Python MCQs (20 Questions)
1️⃣ What is the output of this code?
print(type([]))A. <class 'tuple'>
B. <class 'list'>
C. <class 'dict'>
D. <class 'set'>
✅ Answer: B
2️⃣ Which of the following is mutable in Python?
A. Tuple
B. String
C. List
D. Integer
✅ Answer: C
Example:my_list[0] = 10 is allowed.
3️⃣ What does len("Python") return?
A. 5
B. 6
C. 7
D. Error
✅ Answer: B
4️⃣ What will be the output?
print(3 * "Hi")A. HiHiHi
B. 3Hi
C. Error
D. Hi*3
✅ Answer: A
5️⃣ Which keyword is used to define a function in Python?
A. function
B. define
C. def
D. fun
✅ Answer: C
6️⃣ What is the output?
x = [1, 2, 3]
print(x[-1])A. 1
B. 2
C. 3
D. Error
✅ Answer: C
7️⃣ Which data type is returned by input()?
A. int
B. float
C. string
D. boolean
✅ Answer: C
8️⃣ What does break do in a loop?
A. Skips one iteration
B. Stops the loop completely
C. Restarts loop
D. Causes error
✅ Answer: B
9️⃣ Output of this code?
print(bool(0))A. True
B. False
C. 0
D. None
✅ Answer: B
🔟 Which of these creates a dictionary?
A. {1,2,3}
B. [1:2, 3:4]
C. {1:2, 3:4}
D. (1:2)
✅ Answer: C
1️⃣1️⃣ What is the output?
a = 10
b = a
b = 20
print(a)A. 10
B. 20
C. Error
D. None
✅ Answer: A
1️⃣2️⃣ What does range(1, 5) produce?
A. 1,2,3,4,5
B. 1,2,3,4
C. 0,1,2,3
D. Error
✅ Answer: B
1️⃣3️⃣ What is the output?
print(type({}))A. set
B. list
C. dict
D. tuple
✅ Answer: C
1️⃣4️⃣ Which operator is used for exponentiation?
A. ^
B. **
C. //
D. %%
✅ Answer: B
1️⃣5️⃣ What does continue do?
A. Stops loop
B. Skips current iteration
C. Restarts program
D. Exits function
✅ Answer: B
1️⃣6️⃣ What is the output?
print("Python".upper())A. python
B. PYTHON
C. Python
D. Error
✅ Answer: B
1️⃣7️⃣ Which of these is a valid variable name?
A. 1value
B. value-1
C. value_1
D. value 1
✅ Answer: C
1️⃣8️⃣ Output of this code?
print(5 // 2)A. 2.5
B. 2
C. 3
D. Error
✅ Answer: B
1️⃣9️⃣ What does list(range(3)) return?
A. [1,2,3]
B. [0,1,2]
C. [0,1,2,3]
D. Error
✅ Answer: B
2️⃣0️⃣ Which statement is true about Python?
A. It is statically typed
B. It uses curly braces
C. It supports OOP
D. It does not support functions
✅ Answer: C

Comments
Post a Comment