Learn Python MCQs

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

What is the output of print(5 == 5.0)?

1) True

2) False

3) None

4) Error

Answer : Option 1

How do you create a class method in Python?

1) @classmethod def myMethod(cls):

2) @def myMethod(cls):

3) @class def myMethod(cls):

4) def myMethod(cls):

Answer : Option 1

What is the output of print(len([1, 2, 3]))?

1) 3

2) 2

3) 4

4) Error

Answer : Option 1

How do you sort a list in Python?

1) list.sort()

2) sort(list)

3) sorted(list)

4) Both a and c

Answer : Option 1

Which of the following is a valid list comprehension in Python?

1) [x for x in range(5)]

2) [(x) for x in range(5)]

3) [] for x in range(5)

4) [x in range(5)]

Answer : Option 1

What does the len() function return for a dictionary?

1) The number of keys

2) The number of values

3) The total size

4) None of the above

Answer : Option 1

What is the output of print("Python".find("y"))?

1) 1

2) 0

3) -1

4) 2

Answer : Option 1

Which method is used to convert a string to lowercase in Python?

1) lower()

2) toLower()

3) downcase()

4) lowercase()

Answer : Option 1

What is the output of print(0 == False)?

1) True

2) False

3) None

4) Error

Answer : Option 1

How do you create a new module in Python?

1) myModule.py

2) import myModule

3) module myModule

4) new myModule

Answer : Option 1