Learn Python MCQs

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

What is the output of print(bool(None))?

1) True

2) False

3) None

4) Error

Answer : False

How do you check if a number is odd in Python?

1) number % 2 != 0

2) number % 2 == 1

3) number & 1 == 1

4) None of the above

Answer : number % 2 != 0

What is the output of print(10 % 3)?

1) 1

2) 3

3) 2

4) Error

Answer : 1

How do you create a singleton class in Python?

1) class Singleton:

2) class Singleton(metaclass=SingletonMeta):

3) class Singleton(metaclass=type):

4) None of the above

Answer : class Singleton(metaclass=SingletonMeta):

What is the output of print(2 * "Python")?

1) PythonPython

2) Error

3) 2Python

4) None

Answer : PythonPython

How do you create a list comprehension in Python?

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

2) [x: for x in range(10)]

3) None of the above

4) [for x in range(10): x]

Answer : [x for x in range(10)]

What is the output of print("1" + 1)?

1) Error

2) 11

3) 2

4) None

Answer : Error

How do you convert an integer to a string in Python?

1) str(number)

2) number.str()

3) convert(number)

4) None of the above

Answer : str(number)

How do you raise an exception in Python?

1) raise Exception

2) throw Exception

3) error Exception

4) None of the above

Answer : raise Exception

What is the output of print(0.1 + 0.2 == 0.3)?

1) True

2) False

3) Error

4) None

Answer : False