Learn Python MCQs

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

What is the purpose of the pass statement in Python?

1) No operation

2) Break the loop

3) Continue the loop

4) Return a value

Answer : No operation

How do you create a list in Python?

1) myList = []

2) myList = list()

3) Both a and b

4) myList = {}

Answer : Both a and b

What is the output of print([1, 2, 3] + [4, 5])?

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

2) [5, 7]

3) Error

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

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

Which of the following is used to check the length of a list?

1) length(list)

2) len(list)

3) size(list)

4) count(list)

Answer : len(list)

What will be the output of print(bool(""))?

1) True

2) False

3) None

4) Error

Answer : False

How do you create a multi-line string in Python?

1) s = """Hello"""

2) s = "Hello"

3) s = 'Hello'

4) All of the above

Answer : s = """Hello"""

Which of the following is not a Python built-in function?

1) print()

2) input()

3) length()

4) len()

Answer : length()

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

1) 3

2) 3.33

3) 3.0

4) Error

Answer : 3

How do you convert a list to a set in Python?

1) set(list)

2) list(set)

3) convert(list)

4) None of the above

Answer : set(list)

What is the output of print({1, 2, 3} - {2})?

1) {1, 3}

2) {2}

3) Error

4) {1, 2, 3}

Answer : {1, 3}