Learn Python MCQs

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

What will be the output of print(list(range(5)))?

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

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

3) Error

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

Answer : [0, 1, 2, 3, 4]

Which keyword is used to create an exception in Python?

1) try

2) catch

3) raise

4) throw

Answer : raise

What is the output of print(3 > 2 > 1)?

1) True

2) False

3) None

4) Error

Answer : True

Which of the following methods returns a shallow copy of a list?

1) list.copy()

2) list.clone()

3) list.duplicate()

4) None of the above

Answer : list.copy()

What is the output of print(1 == True)?

1) True

2) False

3) None

4) Error

Answer : True

How do you access the first element of a list in Python?

1) list[0]

2) list(0)

3) list.first()

4) list.firstElement()

Answer : list[0]

What is the output of print("10" + "20")?

1) 1020

2) 30

3) Error

4) 10 + 20

Answer : 1020

How do you round a number in Python?

1) round(number)

2) rounding(number)

3) number.round()

4) math.round()

Answer : round(number)

What is the purpose of the yield keyword in Python?

1) Creates a generator

2) Returns a value

3) Exits a function

4) None of the above

Answer : Creates a generator

What is the output of print("Python"[-1])?

1) n

2) o

3) Error

4) Python

Answer : n