Attempt 100 Python MCQs with answers in this practice set: Python Quiz Test 2026. This set includes Python basics, data types, functions, loops, OOP, exception handling, etc. Useful for coding interviews, online tests, and competitive exams.
100 Python MCQ (Dropdown Format)
Python is slowly becoming one of the most popular programming languages in the world. It is expected that it will soon overtake many other languages due to high demand, especially for AI applications. In this post, we have created a set of 100 Python MCQs with easy explanations. Use this set to help you practice coding, online tests, college or competitive exams.
Read each Python quiz first and try to answer it yourself, then only click the dropdown button next to each question to find the correct answer and explanation.
Q1. Which of the following best describes Python?
A. Low-level language
B. Interpreted language
C. Machine language
D. Assembly language
Show Answer
Answer: B
Python is an interpreted, high-level programming language.
Q2. What is the correct file extension for Python code?
A. .pt
B. .py
C. .pyt
D. .txt
Show Answer
Answer: B
Python source files typically use the .py extension.
Q3. Which keyword is used to define a function in Python?
A. func
B. def
C. function
D. declare
Show Answer
Answer: B
The `def` keyword is used to declare functions in Python.
Q4. Which symbol is used for comments in Python?
A. //
B. /* */
C. #
D. %%
Show Answer
Answer: C
Comments in Python start with the `#` symbol.
Q5. What will `print(type(5.0))` output?
A. int
B. float
C. str
D. bool
Show Answer
Answer: B
The number `5.0` is a floating-point value hence `float`.
Q6. What is the output of `print(2 + 3 * 4)`?
A. 20
B. 14
C. 24
D. 10
Show Answer
Answer: B
Multiplication has higher precedence so 3*4 + 2 = 14.
Q7. Which of these is a mutable data type in Python?
A. tuple
B. list
C. str
D. frozenset
Show Answer
Answer: B
Lists are mutable and can be modified after creation.
Q8. Which loop is used to iterate over a sequence in Python?
A. repeat
B. for
C. until
D. loop
Show Answer
Answer: B
`for` is the loop used to iterate sequences in Python.
Q9. What does `len(“Python”)` return?
A. 5
B. 6
C. 7
D. 8
Show Answer
Answer: B
`len()` returns the number of characters in the string.
Q10. Which function reads input from the user?
A. scan()
B. input()
C. read()
D. get()
Show Answer
Answer: B
`input()` reads text input from the console.
Q11. Which of these is the correct way to import a module?
A. include math
B. import math
C. using math
D. require math
Show Answer
Answer: B
`import` is used to bring modules into a Python script.
Q12. What is the result of `3 == 3`?
A. False
B. True
C. None
D. Error
Show Answer
Answer: B
`==` checks value equality and 3 equals 3.
Q13. Which of the following creates an empty dictionary?
A. {}
B. []
C. ()
D. set()
Show Answer
Answer: A
`{}` initializes an empty dictionary.
Q14. What is the output of `print(10 // 3)`?
A. 3.33
B. 3
C. 4
D. 0
Show Answer
Answer: B
`//` performs integer (floor) division.
Q15. Which keyword is used for exception handling?
A. catch
B. try
C. handle
D. error
Show Answer
Answer: B
`try` is part of the exception handling structure.
Q16. Which of these is a tuple?
A. [1,2]
B. (1,2)
C. {1,2}
D. <1,2>
Show Answer
Answer: B
A tuple is defined with parentheses.
Q17. What does `str(5)` do?
A. Converts to int
B. Converts to string
C. Converts to float
D. Error
Show Answer
Answer: B
`str()` converts values to string type.
Q18. What is the output of `bool(“”)`?
A. True
B. False
C. Error
D. None
Show Answer
Answer: B
Empty strings are considered False in Boolean context.
Q19. Which method adds an element to the end of a list?
A. add()
B. insert()
C. append()
D. extend()
Show Answer
Answer: C
`append()` appends a single element to the list.
Q20. Which operator is used for exponentiation?
A. ^
B. **
C. %
D. //
Show Answer
Answer: B
`**` raises a number to a power.
Q21. What will `print(list(range(3)))` output?
A. [1,2,3]
B. [0,1,2]
C. [3,2,1]
D. Error
Show Answer
Answer: B
`range(3)` produces 0,1,2 in a list.
Q22. What does `x += 2` mean?
A. Increment x by 2
B. Decrement x by 2
C. Set x to 2
D. None
Show Answer
Answer: A
`+=` increases the variable by the given amount.
Q23. Which keyword is used to exit a loop?
A. stop
B. exit
C. break
D. end
Show Answer
Answer: C
`break` stops loop execution.
Q24. How do you check equality of two values?
A. =
B. ==
C. ===
D. !=
Show Answer
Answer: B
`==` checks if values are equal.
Q25. Which of these is a valid Python variable name?
A. 2name
B. myName
C. class
D. $value
Show Answer
Answer: B
Variable names cannot start with numbers or special symbols.
Q26. What will `print(type([1, 2, 3]))` display?
A. list
B. tuple
C. set
D. dict
Show Answer
Answer: A
Square brackets denote a list type in Python.
Q27. What is the output of `print(“a” * 3)`?
A. aaa
B. a3
C. “a3”
D. Error
Show Answer
Answer: A
Multiplying a string repeats it that number of times.
Q28. Which method removes an element from a list by value?
A. pop()
B. delete()
C. remove()
D. discard()
Show Answer
Answer: C
`remove()` deletes the first matching value from the list.
Q29. What does `dict.get(key)` do in Python?
A. Deletes the key
B. Gets value for key
C. Adds new key
D. Always returns None
Show Answer
Answer: B
It returns the value for the given key or None if missing.
Q30. The expression `5 % 2` gives what result?
A. 0
B. 1
C. 2
D. 3
Show Answer
Answer: B
`%` gives the remainder of the division.
Q31. What is the output of `print(bool(0))`?
A. True
B. False
C. Error
D. None
Show Answer
Answer: B
Zero is considered False in Boolean context.
Q32. Which of these is used to skip the current iteration?
A. pass
B. skip
C. continue
D. stop
Show Answer
Answer: C
`continue` jumps to the next loop cycle.
Q33. How do you start a block of code after an `if` statement?
A. Curly braces
B. Parentheses
C. Indentation
D. Semicolon
Show Answer
Answer: C
Python uses indentation to define blocks.
Q34. What does `list.append()` return?
A. New list
B. None
C. Updated list
D. Error
Show Answer
Answer: B
`append()` modifies list in place and returns None.
Q35. What is output of `print(“Python”[1])`?
A. P
B. y
C. t
D. h
Show Answer
Answer: B
Indexing starts at 0 so index 1 is the second character.
Q36. What is the output of `print(min(3, 1, 2))`?
A. 1
B. 2
C. 3
D. None
Show Answer
Answer: A
`min()` returns the smallest value.
Q37. For dictionary `d = {‘x’:1}`, what does `d.keys()` return?
A. list
B. set
C. dict_keys
D. tuple
Show Answer
Answer: C
`keys()` returns a dict_keys object.
Q38. What will `range(1,5)` generate?
A. 0 to 4
B. 1 to 4
C. 1 to 5
D. 5 to 1
Show Answer
Answer: B
Range stops one before end value.
Q39. What is the result of `a == b` when both are lists with same content?
A. True
B. False
C. None
D. Error
Show Answer
Answer: A
`==` checks equality of elements.
Q40. Which method returns a sorted list?
A. list.sort()
B. sorted(list)
C. list.order()
D. list.sorted()
Show Answer
Answer: B
`sorted()` returns a new sorted list.
Q41. What is the output of `print({1,2,3})`?
A. [1,2,3]
B. (1,2,3)
C. {1,2,3}
D. Error
Show Answer
Answer: C
Curly braces with unique items denote a set.
Q42. What will `print(2 ** 3)` output?
A. 5
B. 6
C. 8
D. 9
Show Answer
Answer: C
`**` raises 2 to the power 3.
Q43. What does `len([])` return?
A. 0
B. 1
C. None
D. Error
Show Answer
Answer: A
An empty list has zero elements.
Q44. Which of the following cannot be used as a dictionary key?
A. int
B. str
C. list
D. tuple
Show Answer
Answer: C
Lists are mutable and cannot be dictionary keys.
Q45. What does `x = y` do in Python?
A. Compares x and y
B. Assigns y to x
C. Tests equality
D. Deletes x
Show Answer
Answer: B
`=` is the assignment operator.
Q46. What does the expression 10 > 5 return in Python?
A. 10
B. 5
C. True
D. False
Show Answer
Answer: C
Comparison operators return Boolean values.
Q47. Which operator is used for string concatenation in Python?
A. &
B. +
C. *
D. %
Show Answer
Answer: B
The + operator joins two strings together.
Q48. What is the output of print(type(True))?
A. int
B. str
C. bool
D. float
Show Answer
Answer: C
True and False belong to Boolean type.
Q49. Which statement correctly defines a list in Python?
A. numbers = (1,2,3)
B. numbers = {1,2,3}
C. numbers = [1,2,3]
D. numbers = <1,2,3>
Show Answer
Answer: C
Lists are written using square brackets.
Q50. What does the pass statement do?
A. Skips the loop forever
B. Stops the program
C. Does nothing and continues
D. Clears memory
Show Answer
Answer: C
pass is a null statement used as a placeholder.
Q51. What does the `lambda` keyword define in Python?
A. A loop
B. An anonymous function
C. A class
D. A variable
Show Answer
Answer: B
`lambda` creates an unnamed (anonymous) function.
Q52. What is the output of `d = {‘a’:1, ‘b’:2}; print(d.get(‘c’,3))`?
A. None
B. KeyError
C. 3
D. 0
Show Answer
Answer: C
`get()` returns the default value when key is missing.
Q53. Which statement about tuples is true?
A. Tuples are mutable
B. Tuples are immutable
C. Tuples cannot hold mixed data types
D. Tuples cannot be nested
Show Answer
Answer: B
Tuples cannot be changed after creation.
Q54. What is the result of `s = “python”; print(s[1:4])`?
A. pyth
B. ytho
C. yth
D. tho
Show Answer
Answer: C
Slicing from index 1 up to (but not including) 4.
Q55. What is the purpose of the `global` keyword?
A. To restrict variable scope
B. To declare a global variable inside a function
C. To import global modules
D. To create a local variable
Show Answer
Answer: B
`global` allows modifying a global variable inside a function.
Q56. What will `nums = [1,2,3]; nums.append(nums[:]); print(nums)` output?
A. [1,2,3,1,2,3]
B. [1,2,3]
C. [1,2,3,[1,2,3]]
D. Error
Show Answer
Answer: C
`nums[:]` is a copy and gets appended as a sublist.
Q57. Which of these creates an empty set?
A. {}
B. set()
C. []
D. ()
Show Answer
Answer: B
`{}` creates a dict; `set()` creates an empty set.
Q58. What happens when you run `x=[1,2,3]; y=x; y[0]=4; print(x)`?
A. [4,2,3]
B. [1,2,3]
C. [1,4,3]
D. Error
Show Answer
Answer: A
Both variables reference same list.
Q59. Which describes the `with` statement?
A. To start loops
B. To handle exceptions only
C. To ensure resources close after use
D. To declare variables
Show Answer
Answer: C
`with` ensures clean resource handling, e.g., files.
Q60. What will `print(func(3))` output if `def func(x, y=2): return x+y`?
A. 2
B. 3
C. 5
D. Error
Show Answer
Answer: C
Default `y=2` adds to 3.
Q61. What is the purpose of the `yield` keyword?
A. Terminate loop
B. Return value from generator
C. Define class
D. Raise exception
Show Answer
Answer: B
`yield` returns a value in a generator.
Q62. What is the output of `print(3 * ‘ab’)`?
A. ababab
B. abab
C. ab3
D. Error
Show Answer
Answer: A
String repetition multiplies the pattern.
Q63. Which of the following is NOT a valid way to create a dictionary?
A. dict(a=1,b=2)
B. {‘a’:1,’b’:2}
C. dict([(‘a’,1),(‘b’,2)])
D. {[‘a’]:1,’b’:2}
Show Answer
Answer: D
List key is invalid as dict keys must be hashable.
Q64. What will `lst=[1,2,3]; lst.pop(); print(lst)` output?
A. [1,2,3]
B. [2,3]
C. [1,2]
D. Error
Show Answer
Answer: B
`pop()` removes and returns last element.
Q65. What does the `is` operator check?
A. Identity of objects
B. Value equality
C. Type of variable
D. Membership
Show Answer
Answer: A
`is` checks if two reference same object.
Q66. What will be printed if `global x` in function sets `x = 20` and then prints `x`?
A. 10
B. 20
C. None
D. Error
Show Answer
Answer: B
Global assignment persists after function returns.
Q67. Which is true about list comprehensions?
A. Slower than loops
B. Cannot include conditions
C. Only creates numbers
D. Concise list creation
Show Answer
Answer: D
List comprehensions are compact list builders.
Q68. What will `len({1,2,2,3})` return?
A. 4
B. 2
C. 3
D. Error
Show Answer
Answer: C
Sets remove duplicates.
Q69. What is the purpose of `super()`?
A. Call parent method
B. Create new instance
C. Define static method
D. Raise exception
Show Answer
Answer: A
`super()` accesses parent class methods.
Q70. What will this output: `try: print(1/0) except Exception as e: print(type(e).__name__)`?
A. Exception
B. ZeroDivisionError
C. TypeError
D. Error
Show Answer
Answer: B
The specific exception type name is printed.
Q71. What does the enumerate() function return?
A. Only values
B. Only indexes
C. Both index and value
D. A dictionary
Show Answer
Answer: C
enumerate() gives index–value pairs in loops.
Q72. What is the default return value of a function with no return statement?
A. 0
B. False
C. None
D. Empty string
Show Answer
Answer: C
Functions without return automatically return None.
Q73. Which method converts a list into a tuple?
A. convert()
B. tuple()
C. list()
D. cast()
Show Answer
Answer: B
The tuple() function converts data into tuples.
Q74. Which built-in function returns the maximum value?
A. max()
B. large()
C. highest()
D. top()
Show Answer
Answer: A
max() returns the largest element in an iterable.
Q75. What is the main use of the return statement?
A. Exit program
B. Stop loop
C. Send value back from a function
D. Restart function
Show Answer
Answer: C
return sends a value back to the caller of a function.
Q76. Who created the Python programming language?
A. Dennis Ritchie
B. James Gosling
C. Guido van Rossum
D. Bjarne Stroustrup
Show Answer
Answer: C
Python was created by Guido van Rossum.
Q77. Which built-in function returns the length of an object?
A. length()
B. size()
C. len()
D. count()
Show Answer
Answer: C
`len()` gives the number of items in sequences or collections.
Q78. What type of error is raised by dividing by zero?
A. ValueError
B. ZeroDivisionError
C. TypeError
D. SyntaxError
Show Answer
Answer: B
Dividing by 0 raises `ZeroDivisionError`.
Q79. How do you open a file named “data.txt” for reading?
A. open(“data.txt”, “r”)
B. open(“data.txt”, “w”)
C. open(“data.txt”, “x”)
D. open(“data.txt”, “a”)
Show Answer
Answer: A
`”r”` mode opens a file for reading.
Q80. What method adds an element to a set?
A. add()
B. push()
C. insert()
D. append()
Show Answer
Answer: A
`add()` inserts a new element into a set.
Q81. Which keyword is used to define a class in Python?
A. function
B. class
C. object
D. struct
Show Answer
Answer: B
`class` defines a class.
Q82. What does OOP stand for?
A. Optional Object Programming
B. Object Oriented Programming
C. Ordered Object Protocol
D. Open Operational Program
Show Answer
Answer: B
OOP means Object Oriented Programming.
Q83. Which symbol is used for exponentiation?
A. ^
B. **
C. %
D. //
Show Answer
Answer: B
`**` raises a number to a power.
Q84. Which of the following is *immutable*?
A. list
B. set
C. tuple
D. dict
Show Answer
Answer: C
Tuples cannot be changed after creation.
Q85. What does the `strip()` method do in a string?
A. Adds whitespace
B. Removes whitespace
C. Converts to uppercase
D. Reverses string
Show Answer
Answer: B
It removes leading and trailing whitespace.
Q86. Which keyword catches exceptions?
A. try
B. catch
C. except
D. error
Show Answer
Answer: C
`except` handles exceptions after try.
Q87. What type of loop repeats until a condition is false?
A. for
B. while
C. loop
D. repeat
Show Answer
Answer: B
`while` runs until its condition becomes false.
Q88. Which function converts a string to lowercase?
A. lower()
B. upper()
C. case()
D. swapcase()
Show Answer
Answer: A
`lower()` returns all lowercase characters.
Q89. What will `bool(“False”)` return?
A. False
B. True
C. None
D. Error
Show Answer
Answer: B
Any non-empty string is True.
Q90. What does `pop()` do on a list?
A. Adds item
B. Removes last item
C. Clears list
D. Sorts list
Show Answer
Answer: B
`pop()` removes the last element.
Q91. Which of these checks if a key exists in a dictionary?
A. key in dict
B. dict.contains(key)
C. dict.check(key)
D. exists(dict,key)
Show Answer
Answer: A
Use `in` to test keys.
Q92. What will `print([1,2]+[3,4])` output?
A. [1,2,3,4]
B. [1,2][3,4]
C. [4,6]
D. Error
Show Answer
Answer: A
List concatenation joins lists.
Q93. Which method removes whitespace at both ends?
A. trim()
B. strip()
C. squeeze()
D. clear()
Show Answer
Answer: B
`strip()` removes leading/trailing spaces.
Q94. What is the correct way to start a Python script on Unix?
A. #!/usr/bin/python
B. #!/usr/bin/env python
C. run python
D. start python
Show Answer
Answer: B
This shebang makes scripts executable.
Q95. What will `len({“a”:1,”b”:2})` return?
A. 1
B. 2
C. 0
D. Error
Show Answer
Answer: B
It returns number of keys.
Q96. What does `not` operator do?
A. Logical OR
B. Logical AND
C. Logical NOT
D. Increment
Show Answer
Answer: C
`not` inverts a Boolean.
Q97. What is slicing used for?
A. Changing types
B. Accessing parts of sequences
C. Sorting lists
D. Printing output
Show Answer
Answer: B
Slicing extracts portions of a sequence.
Q98. Which of these is not a keyword in Python?
A. pass
B. eval
C. break
D. continue
Show Answer
Answer: B
`eval` is a built-in function, not a keyword.
Q99. What does `sorted()` return?
A. Sorted list
B. In-place sort
C. None
D. Error
Show Answer
Answer: A
`sorted()` gives a new sorted list.
Q100. A method with two leading and trailing underscores is called?
A. magic method
B. normal method
C. private method
D. protected method
Show Answer
Answer: A
Double underscore methods are magic/special methods.
Conclusion
Practising Python MCQ and quiz questions is one of the best ways to revise concepts and get ready for interviews or coding rounds. We regularly update this page with new quiz questions to keep it fresh and useful. Bookmark it now and check back often for more practice.
You can also continue your preparation with these Python interview questions and answers that cover real interview-asked questions.
Thank you for preparing with us. I wish you the best of luck!
Resources and References:
- Learn Python on the Official Python Documentation
https://docs.python.org/3/ - Python Language Reference (Official Spec Style Docs)
https://docs.python.org/3/reference/ - StackOverflow Python Tag (Community Q&A)
https://stackoverflow.com/questions/tagged/python





