Python Basics MCQ Questions with Answers – Page 2 (Latest 2026)

Practice Python Basics MCQ questions with detailed explanations and clear answer validation. These MCQs help you revise core concepts, compare close options, and improve accuracy for interviews, certification exams, and technical screening rounds. Use this updated 2026 set to strengthen fundamentals and confidence.

Related mcq: Python Advanced Coding MCQ | Python Asyncio MCQ | Python Concurrency MCQ | RAG Basics MCQ | LLM Engineer Basics MCQ

Q51. Which keyword explicitly raises an exception?

Select an answer to check.

Answer: raise

Here, raise is the right choice. Raise is used to trigger exceptions manually. It aligns directly with what the question asks about which keyword explicitly raises an exception. Competing choices sound plausible, but they miss the key condition.

Q52. Which keyword creates a class?

Select an answer to check.

Answer: class

In this case, class is correct. Class defines blueprint for objects. It aligns directly with what the question asks about which keyword creates a class. Competing choices sound plausible, but they miss the key condition.

Q53. Which method initializes object attributes?

Select an answer to check.

Answer: __init__

The best option here is __init__. __init__ runs when instance is created. It aligns directly with what the question asks about which method initializes object attributes. Competing choices sound plausible, but they miss the key condition.

Q54. What does `self` represent?

Select an answer to check.

Answer: Current instance

For this question, Current instance is correct. Self refers to the specific object calling the method. It aligns directly with what the question asks about what does `self` represent. Competing choices sound plausible, but they miss the key condition.

Q55. Which syntax shows inheritance?

Select an answer to check.

Answer: class Child(Parent)

class Child(Parent) is the correct answer here. Parent class is written in parentheses. It aligns directly with what the question asks about which syntax shows inheritance. Competing choices sound plausible, but they miss the key condition.

Q56. Which function checks object type relationship?

Select an answer to check.

Answer: isinstance

Here, isinstance is the right choice. Isinstance(obj, Class) verifies type membership. This matches the core idea being tested around which function checks object type relationship. Competing choices sound plausible, but they miss the key condition.

Q57. Which keyword imports a module?

Select an answer to check.

Answer: import

In this case, import is correct. Import loads module into current namespace. This matches the core idea being tested around which keyword imports a module. Competing choices sound plausible, but they miss the key condition.

Q58. How to import only `sqrt` from `math`?

Select an answer to check.

Answer: from math import sqrt

The best option here is from math import sqrt. From ... import ... imports specific symbol. This matches the core idea being tested around how to import only `sqrt` from `math`. Competing choices sound plausible, but they miss the key condition.

Q59. What does `random.randint(1,3)` include?

Select an answer to check.

Answer: 1,2,3

For this question, 1,2,3 is correct. Randint includes both start and end values. This matches the core idea being tested around what does `random.randint(1,3)` include. Competing choices sound plausible, but they miss the key condition.

Q60. What does `list.sort()` do?

Select an answer to check.

Answer: Sorts list in place

Sorts list in place is the correct answer here. Sort() mutates original list and returns None. This matches the core idea being tested around what does `list.sort()` do. Competing choices sound plausible, but they miss the key condition.

Q61. What does `sorted(list)` do?

Select an answer to check.

Answer: Returns new sorted list

Here, Returns new sorted list is the right choice. Sorted() returns a new list, original remains unchanged. That is exactly the concept behind what does `sorted(list)` do in this context. Competing choices sound plausible, but they miss the key condition.

Q62. Which method reverses list in place?

Select an answer to check.

Answer: reverse()

In this case, reverse() is correct. Reverse() changes order of original list. That is exactly the concept behind which method reverses list in place in this context. Competing choices sound plausible, but they miss the key condition.

Q63. What does `enumerate(list)` provide?

Select an answer to check.

Answer: (index, value) pairs

The best option here is (index, value) pairs. Enumerate adds index while iterating. That is exactly the concept behind what does `enumerate(list)` provide in this context. Competing choices sound plausible, but they miss the key condition.

Q64. What does `zip(a,b)` do?

Select an answer to check.

Answer: Combines iterables by position

For this question, Combines iterables by position is correct. Zip pairs elements from each iterable. That is exactly the concept behind what does `zip(a,b)` do in this context. Competing choices sound plausible, but they miss the key condition.

Q65. When does `any([..])` return True?

Select an answer to check.

Answer: At least one true

At least one true is the correct answer here. Any returns true if any element is truthy. That is exactly the concept behind when does `any([..])` return true in this context. Competing choices sound plausible, but they miss the key condition.

Q66. When does `all([..])` return True?

Select an answer to check.

Answer: All true

Here, All true is the right choice. All returns true only if every element is truthy. It fits the requirement in the prompt about when does `all([..])` return true. Competing choices sound plausible, but they miss the key condition.

Q67. What is `bool('')`?

Select an answer to check.

Answer: False

In this case, False is correct. Empty string is falsy. It fits the requirement in the prompt about what is `bool('')`. Competing choices sound plausible, but they miss the key condition.

Q68. What is `bool('0')`?

Select an answer to check.

Answer: True

The best option here is True. Non-empty strings are truthy, including '0'. It fits the requirement in the prompt about what is `bool('0')`. Competing choices sound plausible, but they miss the key condition.

Q69. What is a common use of set?

Select an answer to check.

Answer: Remove duplicates

For this question, Remove duplicates is correct. Sets keep unique elements only. It fits the requirement in the prompt about what is a common use of set. Competing choices sound plausible, but they miss the key condition.

Q70. Which dictionary method avoids KeyError for missing key?

Select an answer to check.

Answer: get()

get() is the correct answer here. Get returns default (None by default) if key missing. It fits the requirement in the prompt about which dictionary method avoids keyerror for missing key. Competing choices sound plausible, but they miss the key condition.

Q71. What does `pop()` usually do?

Select an answer to check.

Answer: Removes and returns item

Here, Removes and returns item is the right choice. Pop removes element and returns it. This is the most accurate statement for what does `pop()` usually do. Competing choices sound plausible, but they miss the key condition.

Q72. What does `del` do?

Select an answer to check.

Answer: Deletes reference/item

In this case, Deletes reference/item is correct. Del can delete variables or container elements. This is the most accurate statement for what does `del` do. Competing choices sound plausible, but they miss the key condition.

Q73. List indexing starts at?

Select an answer to check.

Answer: 0

The best option here is 0. Python uses zero-based indexing. This is the most accurate statement for list indexing starts at. Competing choices sound plausible, but they miss the key condition.

Q74. What does index `-1` refer to?

Select an answer to check.

Answer: Last item

For this question, Last item is correct. Negative indexing counts from end. This is the most accurate statement for what does index `-1` refer to. Competing choices sound plausible, but they miss the key condition.

Q75. What does `strip()` do on string?

Select an answer to check.

Answer: Removes leading/trailing spaces

Removes leading/trailing spaces is the correct answer here. Strip trims whitespace at both ends. This is the most accurate statement for what does `strip()` do on string. Competing choices sound plausible, but they miss the key condition.

Q76. What does `replace('a','b')` do?

Select an answer to check.

Answer: Returns modified copy

Here, Returns modified copy is the right choice. Strings are immutable; replace returns new string. It aligns directly with what the question asks about what does `replace('a','b')` do. The remaining choices fail because they don’t satisfy the full definition.

Q77. What does `startswith('Py')` check?

Select an answer to check.

Answer: Prefix

In this case, Prefix is correct. Startswith checks beginning of string. It aligns directly with what the question asks about what does `startswith('py')` check. The remaining choices fail because they don’t satisfy the full definition.

Q78. What does `endswith('.py')` check?

Select an answer to check.

Answer: Suffix

The best option here is Suffix. Endswith checks ending of string. It aligns directly with what the question asks about what does `endswith('.py')` check. The remaining choices fail because they don’t satisfy the full definition.

Q79. Which is Python ternary expression?

Select an answer to check.

Answer: a if cond else b

For this question, a if cond else b is correct. Python conditional expression follows this order. It aligns directly with what the question asks about which is python ternary expression. The remaining choices fail because they don’t satisfy the full definition.

Q80. What does `type(x)` return?

Select an answer to check.

Answer: Data type of x

Data type of x is the correct answer here. Type gives class/type of object. It aligns directly with what the question asks about what does `type(x)` return. The remaining choices fail because they don’t satisfy the full definition.

Q81. What does `id(x)` generally represent?

Select an answer to check.

Answer: Unique identity of object

Here, Unique identity of object is the right choice. Id returns integer identity for object during lifetime. This matches the core idea being tested around what does `id(x)` generally represent. The remaining choices fail because they don’t satisfy the full definition.

Q82. What does `dir(obj)` provide?

Select an answer to check.

Answer: Attributes/methods list

In this case, Attributes/methods list is correct. Dir helps inspect available members. This matches the core idea being tested around what does `dir(obj)` provide. The remaining choices fail because they don’t satisfy the full definition.

Q83. What is `help(len)` used for?

Select an answer to check.

Answer: Show documentation

The best option here is Show documentation. Help displays docs for objects/functions. This matches the core idea being tested around what is `help(len)` used for. The remaining choices fail because they don’t satisfy the full definition.

Q84. What numbers are in `range(1,10,2)`?

Select an answer to check.

Answer: 1,3,5,7,9

For this question, 1,3,5,7,9 is correct. Starts at 1, step 2, stops before 10. This matches the core idea being tested around what numbers are in `range(1,10,2)`. The remaining choices fail because they don’t satisfy the full definition.

Q85. What does `map(func, items)` do?

Select an answer to check.

Answer: Applies function to items

Applies function to items is the correct answer here. Map transforms each element with given function. This matches the core idea being tested around what does `map(func, items)` do. The remaining choices fail because they don’t satisfy the full definition.

Q86. What does `filter(func, items)` do?

Select an answer to check.

Answer: Keeps matching items

Here, Keeps matching items is the right choice. Filter returns items where predicate is truthy. That is exactly the concept behind what does `filter(func, items)` do in this context. The remaining choices fail because they don’t satisfy the full definition.

Q87. What does `sum([1,2,3])` return?

Select an answer to check.

Answer: 6

In this case, 6 is correct. Sum adds all numeric elements. That is exactly the concept behind what does `sum([1,2,3])` return in this context. The remaining choices fail because they don’t satisfy the full definition.

Q88. What does `max([3,1,7])` return?

Select an answer to check.

Answer: 7

The best option here is 7. Max returns largest element. That is exactly the concept behind what does `max([3,1,7])` return in this context. The remaining choices fail because they don’t satisfy the full definition.

Q89. What does `min([3,1,7])` return?

Select an answer to check.

Answer: 1

For this question, 1 is correct. Min returns smallest element. That is exactly the concept behind what does `min([3,1,7])` return in this context. The remaining choices fail because they don’t satisfy the full definition.

Q90. What does `abs(-9)` return?

Select an answer to check.

Answer: 9

9 is the correct answer here. Abs returns absolute magnitude. That is exactly the concept behind what does `abs(-9)` return in this context. The remaining choices fail because they don’t satisfy the full definition.

Q91. What does `round(2.4)` return?

Select an answer to check.

Answer: 2

Here, 2 is the right choice. 2.4 rounds to nearest integer 2. It fits the requirement in the prompt about what does `round(2.4)` return. The remaining choices fail because they don’t satisfy the full definition.

Q92. What kind of copy is `list.copy()`?

Select an answer to check.

Answer: Shallow copy

In this case, Shallow copy is correct. Copy duplicates top-level list only. It fits the requirement in the prompt about what kind of copy is `list.copy()`. The remaining choices fail because they don’t satisfy the full definition.

Q93. For lists, what does `==` compare?

Select an answer to check.

Answer: Values

The best option here is Values. == checks element-wise value equality. It fits the requirement in the prompt about for lists, what does `==` compare. The remaining choices fail because they don’t satisfy the full definition.

Q94. For objects, what is `is` best used for?

Select an answer to check.

Answer: Identity comparison

For this question, Identity comparison is correct. Is tests whether two names reference same object. It fits the requirement in the prompt about for objects, what is `is` best used for. The remaining choices fail because they don’t satisfy the full definition.

Q95. Which collection is mutable?

Select an answer to check.

Answer: list

list is the correct answer here. Lists can be modified in place. It fits the requirement in the prompt about which collection is mutable. The remaining choices fail because they don’t satisfy the full definition.

Q96. Can you append directly to a tuple?

Select an answer to check.

Answer: No

Here, No is the right choice. Tuple is immutable; no append method. This is the most accurate statement for can you append directly to a tuple. The remaining choices fail because they don’t satisfy the full definition.

Q97. Default iteration over dictionary gives?

Select an answer to check.

Answer: Keys

In this case, Keys is correct. For x in dict iterates over keys by default. This is the most accurate statement for default iteration over dictionary gives. The remaining choices fail because they don’t satisfy the full definition.

Q98. How to iterate key-value pairs in dictionary `d`?

Select an answer to check.

Answer: d.items()

The best option here is d.items(). Items returns iterable of (key, value) pairs. This is the most accurate statement for how to iterate key-value pairs in dictionary `d`. The remaining choices fail because they don’t satisfy the full definition.

Q99. What does `list(range(3))` produce?

Select an answer to check.

Answer: [0,1,2]

For this question, [0,1,2] is correct. Range stop is exclusive. This is the most accurate statement for what does `list(range(3))` produce. The remaining choices fail because they don’t satisfy the full definition.

Q100. What is the output of `len([])`?

Select an answer to check.

Answer: 0

0 is the correct answer here. Empty list has length 0. This is the most accurate statement for what is the output of `len([])`. The remaining choices fail because they don’t satisfy the full definition.