Learn Python MCQs
Prepare Python MCQs (Multiple choice Questions) for exam and job interviews.
Which of the following is a Python framework for web development?
1) Flask
2) Django
3) Bottle
4) All of the above
Answer : All of the above
What does the map() function do in Python?
1) Applies a function to all items in an iterable
2) Filters items in an iterable
3) Creates a new iterable
4) Sorts items in an iterable
Answer : Applies a function to all items in an iterable
What is the output of print([1, 2, 3] + [4, 5])?
1) [1, 2, 3, 4, 5]
2) [5, 7, 8]
3) [1, 2, 3, 4] + [5]
4) [1, 2, 3][4, 5]
Answer : [1, 2, 3, 4, 5]
Which of the following methods is used to add an element at the end of a list?
1) add()
2) insert()
3) append()
4) extend()
Answer : append()
What is the output of print(2 == "2")?
1) True
2) False
3) None
4) Error
Answer : False
How do you create a virtual environment in Python?
1) python -m venv myenv
2) python create venv myenv
3) python venv myenv
4) venv create myenv
Answer : python -m venv myenv
What is the output of print("Hello"[0])?
1) H
2) e
3) o
4) Hello
Answer : H
What is the keyword to define a generator function in Python?
1) def
2) yield
3) return
4) function
Answer : def
What will be the output of print("Hello".upper())?
1) HELLO
2) hello
3) Hello
4) Error
Answer : HELLO
Which of the following is used to handle multiple exceptions in Python?
1) try/except
2) try/catch
3) catch/throw
4) try/finally
Answer : try/except