10 Python MCQs with Answers (Beginner to Advanced)
🟢 Beginner Level (1–40)
1. Python is a:
A) Compiled language
B) Interpreted language
C) Assembly language
D) Machine language
Answer: B
2. Which symbol is used for comments?
A) //
B) <!– –>
C) #
D) /* */
Answer: C
3. What is the output of print(type(5))?
A) int
B) <class ‘int’>
C) number
D) integer
Answer: B
4. Which keyword defines a function?
A) func
B) define
C) def
D) function
Answer: C
5. What is the output of 5 // 2?
A) 2.5
B) 3
C) 2
D) 2.0
Answer: C
6. Which data type is mutable?
A) Tuple
B) String
C) List
D) Integer
Answer: C
7. What is the output of len("Python")?
A) 5
B) 6
C) 7
D) Error
Answer: B
8. Which keyword is used for loops?
A) repeat
B) loop
C) for
D) iterate
Answer: C
9. Which operator is used for multiplication?
A) x
B) *
C) %
D) #
Answer: B
10. What is the output of 2**3?
A) 6
B) 8
C) 9
D) 5
Answer: B
11. What is the output of 10 % 3?
A) 3
B) 1
C) 0
D) 10
Answer: B
12. Which of these is a string?
A) 123
B) “123”
C) 12.3
D) True
Answer: B
13. Which function is used for input?
A) get()
B) read()
C) input()
D) scan()
Answer: C
14. Which keyword is used for conditional statements?
A) if
B) check
C) when
D) case
Answer: A
15. What is the output of print(bool(1))?
A) False
B) True
C) None
D) Error
Answer: B
16. Which data type is immutable?
A) List
B) Dictionary
C) Tuple
D) Set
Answer: C
17. Which function converts string to integer?
A) str()
B) int()
C) float()
D) chr()
Answer: B
18. What is the output of "Hi" * 2?
A) HiHi
B) Hi 2
C) Error
D) HiHiHi
Answer: A
19. Which symbol is used for assignment?
A) ==
B) =
C) !=
D) :=
Answer: B
20. What is the output of 3 > 2?
A) True
B) False
C) Error
D) None
Answer: A
21. Which is a valid variable name?
A) 1name
B) name_1
C) name-1
D) name 1
Answer: B
22. What is the output of len([1,2,3])?
A) 2
B) 3
C) 1
D) Error
Answer: B
23. Which of these is a list?
A) (1,2,3)
B) [1,2,3]
C) {1,2,3}
D) “123”
Answer: B
24. Which of these is a dictionary?
A) [1,2]
B) {1,2}
C) {“a”:1}
D) (1,2)
Answer: C
25. What is the output of type([])?
A) list
B) tuple
C) dict
D) set
Answer: A
26. Which function prints output?
A) echo()
B) print()
C) output()
D) show()
Answer: B
27. Which keyword exits loop?
A) stop
B) break
C) exit
D) return
Answer: B
28. Which keyword skips iteration?
A) skip
B) continue
C) pass
D) next
Answer: B
29. What is the output of 4 == 4.0?
A) True
B) False
C) Error
D) None
Answer: A
30. Which function gives length?
A) size()
B) count()
C) len()
D) length()
Answer: C
31–40 (concise to keep readable)
bool("")→ B Falseint("5")→ A 53+2*2→ B 710/2→ A 5.0"a"+"b"→ A abmin(1,2)→ A 1max(1,2)→ B 2abs(-5)→ A 5round(2.6)→ B 3type({})→ C dict
🟡 Intermediate Level (41–80)
- append() → B add end
- pop() → A remove element
- sort() → C sort list
len("Hi")→ B 210//3→ B 3- strip() → A remove spaces
- replace() → B replace text
- split() → C split string
- join() → A join list
- keys() → A dict keys
- values() → B dict values
- items() → C key-value pairs
in→ A membership operatoris→ B identity operator- lambda → C anonymous function
- map() → B apply function
- filter() → C filter items
- reduce() → A cumulative result
- range(3) → B 0,1,2
- enumerate() → A index + value
- zip() → B combine iterables
- open() → A open file
- read() → B read file
- write() → C write file
- close() → A close file
- try → A exception block
- except → B catch error
- finally → C always run
- raise → A throw error
- assert → B debug check
71–80 (short):
71. global → A global var
72. nonlocal → B outer var
73. dir() → A list attributes
74. help() → B documentation
75. id() → C memory id
76. type() → A type check
77. isinstance() → B type check
78. sorted() → A sorted list
79. reversed() → B reverse iterator
80. sum([1,2]) → A 3
🔵 Advanced Level (81–110)
- generator → B yield function
- yield → A return generator value
- decorator → C modify function
@staticmethod→ A static method@classmethod→ B class method__init__→ A constructor__str__→ B string representation__len__→ C length override__del__→ A destructor- inheritance → B reuse class
- polymorphism → A many forms
- encapsulation → B data hiding
- abstraction → C hide complexity
- threading → A parallel tasks
- multiprocessing → B multi CPU
- GIL → A global interpreter lock
- list comprehension → B compact loop
- dict comprehension → C dict creation
- set comprehension → A set creation
frozenset→ B immutable setcollections→ A advanced DSitertools→ B iterator toolsfunctools→ C function toolssys→ A system functionsos→ B OS interaction- virtualenv → A env isolation
- pip → B package manager
- wheel → C package format
- docstring → A documentation
- PEP → B Python standards