100 Python MCQ Questions with Answers (Free 100 Quiz for Practice)
“100 Python MCQ Questions with Answers (Free 100 Quiz for Practice)
Python MCQ Questions with Answers is a powerful way to revise Python basics, practice for exams, and prepare for coding interviews using real-world style questions. This post gives you 100 quiz questions covering Python fundamentals, operators, strings, lists, functions, tuples, sets, dictionaries, conditionals, and loops. Each question comes with a clear answer so you can quickly check your understanding and learn from mistakes. Use this 100 quiz as a self-assessment tool to track your progress in Python. Bookmark this page and try the quiz again later.
How to Use This 100 Python Quiz
This 100 Python quiz is best for beginners, students, and job seekers who want to strengthen their core Python concepts in a structured way. Read each question carefully, think about the answer, and try to solve it yourself before checking the bold correct answer. This active recall method will help you remember syntax, rules, and common patterns more effectively. You can also time yourself to simulate exam or interview conditions.
Basic Python MCQ Questions (1–30)
In this section you will cover intro to Python, syntax, variables, data types, and basic input/output related questions. These MCQs help you build a strong foundation before moving to operators, strings, collections, and control flow. Treat this part as your warm-up to test how comfortable you are with Python fundamentals, installation, and basic functions.
1.
Which of the following is the correct file extension for a Python file?
A) .pyth
B) .pt
C) .py
D) .p
Answer: C
Python is best described as a:
A) Low-level language
B) High-level, interpreted language
C) High-level, compiled language
D) Machine language
Answer: B
Who created the Python programming language?
A) James Gosling
B) Guido van Rossum
C) Dennis Ritchie
D) Bjarne Stroustrup
Answer: B
Which symbol is used to start a comment in Python?
A) //
B) <!--
C) #
D) **
Answer: C
What will print(type(10)) output?
A) <class 'float'>
B) <class 'str'>
C) <class 'int'>
D) <class 'bool'>
Answer: C
Which of these is a valid variable name in Python?
A) 2value
B) value_2
C) value-2
D) value 2
Answer: B
Which function is used to get input from the user as a string?
A) read()
B) input()
C) scan()
D) gets()
Answer: B
What is the output of print(3 + 2 * 2)?
A) 10
B) 7
C) 8
D) 9
Answer: B
Which keyword is used to define a function in Python?
A) function
B) fun
C) def
D) define
Answer: C
Which of the following is not a core data type in Python?
A) List
B) Tuple
C) Class
D) Dictionary
Answer: C
What is the output of print("Hello" + " " + "Python")?
A) HelloPython
B) Hello Python
C) "Hello Python"
D) Error
Answer: B
What will print(10 / 4) output in Python 3?
A) 2
B) 2.0
C) 2.5
D) 3
Answer: C
Which function is used to display something on the screen?
A) out()
B) echo()
C) print()
D) show()
Answer: C
What is the correct way to create a single-line string?
A) str = "Hello"
B) str = 'Hello'
C) Both A and B
D) Neither A nor B
Answer: C
Which operator is used for exponentiation in Python?
A) ^
B) **
C) ^^
D) //
Answer: B
What is the result of len("Python")?
A) 5
B) 6
C) 7
D) 8
Answer: B
What is the output of print(bool(0))?
A) True
B) False
C) 0
D) 1
Answer: B
Which of the following is used to convert a string "10" to an integer?
A) int("10")
B) str("10")
C) float("10")
D) bool("10")
Answer: A
Python code blocks are defined by:
A) Braces {}
B) Parentheses ()
C) Indentation
D) Semicolons
Answer: C
Which of the following is a reserved keyword in Python?
A) main
B) var
C) for
D) print
Answer: C
What is the output of print(5 == 5.0)?
A) True
B) False
C) Error
D) None
Answer: A
Which built-in function returns the largest item in an iterable?
A) max()
B) big()
C) high()
D) largest()
Answer: A
Which of the following is the correct way to start a Python interpreter from the terminal?
A) py
B) python or python3 (depends on system)
C) runpython
D) startpy
Answer: B
Which data type can store True or False values?
A) int
B) bool
C) str
D) float
Answer: B
What is the output of print(2 ** 3)?
A) 6
B) 8
C) 9
D) 5
Answer: B
What is the output of print("5" * 3)?
A) 15
B) 8
C) 555
D) Error
Answer: C
Which of these is the correct way to write a multi-line comment?
A) /* comment */
B) <!-- comment -->
C) """ comment """
D) ## comment ##
Answer: C
What is the output of print(type(3.14))?
A) <class 'int'>
B) <class 'float'>
C) <class 'double'>
D) <class 'decimal'>
Answer: B
Which function gives the absolute value of a number?
A) abs()
B) absolute()
C) mod()
D) val()
Answer: A
Which of the following is used to end a line in Python print by default?
A) Space
B) Newline \n
C) Tab \t
D) Nothing
Answer: B
Python Operators, Strings and Lists MCQ (31–60)
These Python MCQ questions focus on arithmetic, comparison, logical operators, as well as string and list methods you use every day. You will practice concepts like floor division, modulo, membership tests, indexing, slicing, concatenation, and common list operations. Mastering this section will make your code more expressive and help you solve algorithmic problems efficiently.
Operators, strings, lists (31–60)
Which operator is used for floor division in Python?
A) /
B) //
C) %
D) **
Answer: B
What is the output of print(10 % 3)?
A) 3
B) 1
C) 0.3
D) 0
Answer: B
Which operator is used to check equality?
A) =
B) ==
C) ===
D) :
Answer: B
What is the result of "Python".lower()?
A) PYTHON
B) python
C) Python
D) error
Answer: B
What is the output of "python".upper()?
A) python
B) PYTHON
C) Python
D) error
Answer: B
Which operator is used for string concatenation?
A) +
B) &
C) .
D) ,
Answer: A
How do you access the first character of a string s = "Python"?
A) s(0)
B) s
C) s
D) s.first()
Answer: C
What is the output of print(len([1, 2, 3, 4]))?
A) 3
B) 4
C) 5
D) Error
Answer: B
Which method adds an element at the end of a list?
A) add()
B) append()
C) insert()
D) extend()
Answer: B
Which method removes and returns the last element of a list?
A) pop()
B) remove()
C) delete()
D) discard()
Answer: A
What is the output of print([1, 2] + [3, 4])?
A)
B) [1, 2, ]
C)
D) Error
Answer: A
Which of the following creates an empty list?
A) list = {}
B) list = []
C) list = ()
D) list = set()
Answer: B
What is the index of the last element in a list of length n?
A) n
B) n - 1
C) n + 1
D) 0
Answer: B
Which list method is used to sort elements in ascending order?
A) order()
B) sort()
C) arrange()
D) asc()
Answer: B
What is the output of "Python"[1:4]?
A) Pyt
B) yth
C) ytho
D) Pyth
Answer: B
Which operator is used to check membership in a list?
A) in
B) has
C) of
D) contains
Answer: A
What is the output of print(2 in [1, 2, 3])?
A) 2
B) True
C) False
D) Error
Answer: B
Which method removes the first occurrence of an element from a list?
A) delete()
B) pop()
C) remove()
D) discard()
Answer: C
What is the output of print("a" * 4)?
A) a4
B) 4a
C) aaaa
D) Error
Answer: C
Which of the following is an immutable sequence?
A) List
B) Tuple
C) Dictionary
D) Set
Answer: B
What is the output of print([1, 2, 3][0])?
A) 0
B) 1
C) 2
D) 3
Answer: B
Which function returns the smallest value in a list?
A) low()
B) min()
C) small()
D) least()
Answer: B
What is the output of print("Python".find("t"))?
A) 0
B) 2
C) 3
D) -1
Answer: B
Which method splits a string into a list of words?
A) cut()
B) divide()
C) split()
D) break()
Answer: C
What is the output of "Hello World".replace("World", "Python")?
A) Hello
B) Python
C) Hello Python
D) Hello World Python
Answer: C
Which operator returns True only if both conditions are True?
A) or
B) not
C) and
D) &
Answer: C
What is the result of not True?
A) True
B) False
C) 1
D) 0
Answer: B
Which expression checks if x is not equal to 10?
A) x =! 10
B) x <> 10
C) x != 10
D) x not 10
Answer: C
What is the output of print(3 > 2 and 2 > 1)?
A) True
B) False
C) 3
D) 1
Answer: A
Which operator is used for modulo operation?
A) /
B) %
C) //
D) **
Answer: B
Functions, Tuples, Sets and Dictionaries MCQ (61–85)
This part covers def, return, arguments, default values, and the immutability of tuples, along with set uniqueness and dictionary key rules. You will see how Python functions behave, how tuples differ from lists, and why sets automatically remove duplicates. Understanding these concepts will give you more control over data structures and memory usage in your Python programs.
Functions, tuples, sets, dicts (61–85)
Which keyword is used to return a value from a function?
A) break
B) exit
C) return
D) stop
Answer: C
What is the output of:
python
def add(a, b):
return a + b
print(add(2, 3))
text
A) 23
B) 5
C) 2 + 3
D) Error
Answer: B
63. Which is the correct way to call a function greet()?
A) call greet
B) greet
C) greet()
D) function greet()
Answer: C
A function that does not return any value returns:
A) 0
B) False
C) None
D) ""
Answer: C
Which of the following is a tuple?
A)
B) (1, 2, 3)
C) {1, 2, 3}
D) {"a": 1, "b": 2}
Answer: B
What is the output of len((1, 2, 3))?
A) 2
B) 3
C) 4
D) Error
Answer: B
Which statement about tuples is true?
A) Tuples are mutable
B) Tuples are immutable
C) Tuples are dictionaries
D) Tuples are sets
Answer: B
Which of the following creates an empty set?
A) {}
B) set()
C) []
D) ()
Answer: B
What is the output of set([1, 2, 2, 3])?
A) {1, 2, 2, 3}
B) {1, 2, 3}
C)
D) Error
Answer: B
Which statement about sets is true?
A) Sets allow duplicate elements
B) Sets are ordered
C) Sets do not allow duplicates
D) Sets are immutable
Answer: C
Which of the following is a dictionary?
A) {1, 2, 3}
B) {"a": 1, "b": 2}
C)
D) (1, 2, 3)
Answer: B
Dictionary keys must be:
A) Mutable
B) Immutable
C) Lists
D) Sets
Answer: B
How do you access the value for key "name" in dictionary d?
A) d("name")
B) d.name
C) d["name"]
D) d->"name"
Answer: C
What does d.keys() return for a dictionary d?
A) List of values
B) List of keys
C) Single key
D) None
Answer: B
Which method adds a new key–value pair to a dictionary?
A) add()
B) insert()
C) update()
D) extend()
Answer: C
What is the output of:
python
d = {"a": 1, "b": 2}
print(len(d))
text
A) 1
B) 2
C) 3
D) Error
Answer: B
77. Which of the following can be used as a dictionary key?
A) List
B) Set
C) Tuple
D) Dictionary
Answer: C
What is the output of:
python
def func(x=5):
print(x)
func()
text
A) 0
B) 5
C) None
D) Error
Answer: B[3]
79. Which parameter type allows you to pass a variable number of arguments?
A) *args
B) &args
C) varargs
D) manyargs
Answer: A
Which keyword is used for an anonymous function in Python?
A) lambda
B) anon
C) def
D) func
Answer: A
What is the output of:
python
square = lambda x: x * x
print(square(3))
text
A) 3
B) 6
C) 9
D) Error
Answer: C
82. What does the range(5) function produce?
A) 1, 2, 3, 4, 5
B) 0, 1, 2, 3, 4
C) 0, 1, 2, 3, 4, 5
D) 1, 2, 3, 4
Answer: B
How do you define a function with no parameters?
A) def func:
B) def func()
C) func()
D) function func()
Answer: B
Which keyword is used to specify a default value for a parameter?
A) default
B) value
C) = after parameter name
D) None
Answer: C
What is the output of:
python
t = (1, 2, 3)
print(t[1])
text
A) 1
B) 2
C) 3
D) Error
Answer: B
Conditional Statements and Loops MCQ (86–100)
The last section tests your understanding of if-elif-else, for and while loops, and the use of break and continue in control flow. These questions mirror real-world logic building in scripts and interview-style puzzles. Practicing them will help you write cleaner loops, avoid infinite executions, and handle complex branching in your Python programs.
Conditionals and loops (86–100)
Which keyword starts an if statement?
A) when
B) if
C) condition
D) test
Answer: B
What is the output of:
python
x = 10
if x > 5:
print("Greater")
else:
print("Smaller")
text
A) Greater
B) Smaller
C) 10
D) Error
Answer: A[2]
88. Which keyword is used for an alternative condition in an if statement?
A) elseif
B) else if
C) elif
D) other
Answer: C
What is the output of:
python
for i in range(3):
print(i)
text
A) 1 2 3
B) 0 1 2
C) 0 1 2 3
D) 1 2
Answer: B[1]
90. Which loop is used when the number of iterations is not known beforehand?
A) for
B) while
C) do-while
D) repeat
Answer: B
What does the break statement do inside a loop?
A) Skips one iteration
B) Ends the loop
C) Restarts the loop
D) Pauses the loop
Answer: B
What does the continue statement do?
A) Ends the loop
B) Skips the rest of the current iteration
C) Restarts the program
D) Stops the program
Answer: B
What is the output of:
python
i = 1
while i < 4:
print(i)
i += 1
text
A) 1 2 3 4
B) 1 2 3
C) 0 1 2
D) Infinite loop
Answer: B
94. Which statement is used to do nothing in a loop or function?
A) stop
B) skip
C) pass
D) None
Answer: C
What is the output of:
python
for ch in "hi":
print(ch)
text
A) hi
B) h
i
C) Error
D) h i hi
Answer: B
96. Which of the following correctly checks if a list is empty?
A) if list == []:
B) if not list:
C) Both A and B
D) None of these
Answer: C
What is the output of:
python
for i in range(1, 6, 2):
print(i)
text
A) 1 2 3 4 5
B) 1 3 5
C) 2 4 6
D) 0 2 4
Answer: B[1]
98. Which keyword is used to start a for loop?
A) loop
B) for
C) each
D) repeat
Answer: B
What is the output of:
python
x = 5
if x == 5:
print("Five")
elif x > 3:
print("Greater than three")
else:
print("Less than five")
text
A) Five
B) Greater than three
C) Less than five
D) Error
Answer: A[2]
100. In Python, an else block can be used with:
A) if only
B) for and while loops
C) try-except blocks
D) All of the above
Answer: D
More Python Quiz Posts You’ll Love
If you enjoyed these 100 Python MCQ questions with answers and want to practice more topic-wise quizzes, check out the following posts:
टिप्पणियाँ
एक टिप्पणी भेजें