Learn Python MCQs
Prepare Python MCQs (Multiple choice Questions) for exam and job interviews.
What will be the output of print(10 % 3)?
1) 3
2) 1
3) 2
4) 0
Answer : 1
Which of the following is a valid way to create a string in Python?
1) s = "Hello"
2) s = 'Hello'
3) s = """Hello"""
4) All of the above
Answer : All of the above
What does the break statement do in a loop?
1) Exits the loop
2) Continues to the next iteration
3) Stops the program
4) Raises an exception
Answer : Exits the loop
What is the output of print(bool(1))?
1) True
2) False
3) None
4) 0
Answer : True
What will be the output of print([1, 2, 3] == [1, 2, 3])?
1) True
2) False
3) Error
4) None
Answer : True
How do you remove duplicates from a list in Python?
1) set(list)
2) list(set)
3) list.unique()
4) list.removeDuplicates()
Answer : list(set)
What is the output of print(len("Python"))?
1) 6
2) 5
3) 7
4) 8
Answer : 6
Which of the following is a Python library for data manipulation?
1) Pandas
2) NumPy
3) Matplotlib
4) All of the above
Answer : All of the above
How do you create a while loop in Python?
1) while condition:
2) loop condition:
3) do while condition:
4) repeat until condition:
Answer : while condition:
What is the output of print("Hello, World!".split(","))?
1) ["Hello", " World!"]
2) ["Hello World!"]
3) ["Hello,", "World!"]
4) Error
Answer : ["Hello", " World!"]