Learn Python MCQs

Prepare Python MCQs (Multiple choice Questions) for exam and job interviews.

What is the purpose of the __init__ method in a class?

1) Initialize object attributes

2) Define class methods

3) Create class variables

4) Terminate the class

Answer : Option 1

Which keyword is used to inherit a class in Python?

1) extends

2) inherits

3) super

4) class

Answer : Option 1

What will be the output of print("A" in ["A", "B", "C"])?

1) True

2) False

3) None

4) 0

Answer : Option 1

What is the correct way to create a set in Python?

1) mySet = {}

2) mySet = set()

3) mySet = []

4) mySet = ()

Answer : Option 1

How do you create a tuple in Python?

1) myTuple = ()

2) myTuple = []

3) myTuple = {}

4) myTuple = tuple()

Answer : Option 1

Which of the following is not a valid variable name in Python?

1) myVar

2) my-var

3) my_var

4) myVar2

Answer : Option 1

What is the purpose of the continue statement in a loop?

1) Skip the current iteration

2) Stop the loop

3) Exit the loop

4) Restart the loop

Answer : Option 1

What will be the output of print(type([]))?

1)

2)

3)

4)

Answer : Option 1

How do you define a default argument in a function?

1) def myFunc(arg1, arg2=default):

2) def myFunc(arg1, arg2):

3) def myFunc(arg1:default):

4) def myFunc(arg1=default):

Answer : Option 1

What is the output of print(range(5))?

1) 0 1 2 3 4

2) [0, 1, 2, 3, 4]

3) range(0, 5)

4) 0 1 2 3 4 5

Answer : Option 1