Showing posts with label O Level MCQ. Show all posts
Showing posts with label O Level MCQ. Show all posts

Thursday, December 12, 2024

Top O Level Python MCQ Questions: Learn & Test Your Knowledge

Top 10 Python MCQ For NIELIT O level


 1. What is the output of the following Python code?

x = [1, 2, 3, 4] print(x[2:])

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?

x = 5 print(x == 5)

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?

x = "Hello" y = "World" print(x + " " + y)

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?

x = [1, 2, 3] y = x y[1] = 4 print(x)

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:

  1. b) [2, 3, 4]
  2. b) def function()
  3. a) True
  4. a) d = {key1: value1, key2: value2}
  5. d) Tuple
  6. a) class MyClass:
  7. b) Hello World
  8. b) len(list)
  9. b) [1, 4, 3]
  10. a) re

KAiSH Computer Institute, Lucknow: Join One Course, Get Multiple Certificates – A Golden Opportunity in Uttar Pradesh

KAiSH Computer Institute, Lucknow: Join One Course, Get Multiple Certificates – A Golden Opportunity in Uttar Pradesh If you...