Basic Python MCQ Questions with Answers
1. What is the correct file extension for Python files?
a) .pyt
b) .pt
c) .py (Answer)
d) .python
2. Which keyword is used to define a function in Python?
a) def (Answer)
b) func
c) function
d) define
3. What is the output of: print(2 + 3 * 4)?
a) 20
b) 14 (Answer)
c) 24
d) 18
4. Which data type is used to store text in Python?
a) int
b) str (Answer)
c) float
d) bool
5. What does len() function do in Python?
a) Counts numbers
b) Adds values
c) Returns the length (Answer)
d) Loops through items
6. Which of these is a valid variable name in Python?
a) 1name
b) name1 (Answer)
c) @name
d) name-1
7. What is the output of: print("Hello" + "World")?
a) Hello World
b) Hello+World
c) HelloWorld (Answer)
d) Error
8. What is the output of type(10.5)?
a) int
b) float (Answer)
c) str
d) double
9. Which of the following is a loop structure in Python?
a) iterate
b) repeat
c) for (Answer)
d) loop
10. What does the input() function do?
a) Prints text
b) Takes user input (Answer)
c) Exits program
d) Stores data
11. Which symbol is used for comments in Python?
a) //
b) <!--
c) # (Answer)
d) **
12. What will be the output of print(bool(0))?
a) True
b) False (Answer)
c) 0
d) Error
13. Which operator is used for exponentiation (power) in Python?
a) ^
b) ** (Answer)
c) %
d) //
14. What will be the output of: print(9 // 2)?
a) 4.5
b) 5 (Answer)
c) 4
d) 4.0
15. Which of the following is not a Python data type?
a) list
b) set
c) array (Answer)
d) tuple