Top 10 Python MCQ For NIELIT O level
1. What is the output of the following Python code?
a) [1, 2, 3]
b) [2, 3, 4]
c) [3, 4]
d) [1, 2]
2. Which of the following is used to define a function in Python?
a) function()
b) def function()
c) func()
d) define function()
3. What will be the output of the following Python code?
a) True
b) False
c) Error
d) None
4. What is the correct syntax to create a dictionary in Python?
a) d = {key1: value1, key2: value2}
b) d = (key1: value1, key2: value2)
c) d = [key1: value1, key2: value2]
d) d = key1: value1, key2: value2
5. Which of the following Python data types is immutable?
a) List
b) Dictionary
c) Set
d) Tuple
6. What is the correct way to create a class in Python?
a) class MyClass:
b) create MyClass:
c) define MyClass:
d) class: MyClass
7. What is the output of the following code?
a) HelloWorld
b) Hello World
c) "Hello" "World"
d) None
8. Which method is used to get the length of a list in Python?
a) list.length()
b) len(list)
c) size(list)
d) list.size()
9. What will be the output of the following code?
a) [1, 2, 3]
b) [1, 4, 3]
c) [4, 2, 3]
d) Error
10. Which Python module provides regular expression functionality?
a) re
b) regex
c) reg
d) regexp
Answers:
- b) [2, 3, 4]
- b) def function()
- a) True
- a) d = {key1: value1, key2: value2}
- d) Tuple
- a) class MyClass:
- b) Hello World
- b) len(list)
- b) [1, 4, 3]
- a) re