Home
MCQs by exam
Python Interview Control Flow
Data Science
Python Interview Control Flow MCQs – Data Science
15 multiple choice questions typical of the Python Interview Control Flow exam, with answers and explanations. Switch on practice mode to test yourself first.
for i, c in enumerate('ab'):
print(c, i)
A
0 a
1 b
B
a b
C
a 0
b 1
Correct answer
D
Error
for i in range(2):
print(i)
A
0
1
Correct answer
B
1
2
C
0
1
2
D
Error
print(list(zip([1, 2], ['a'])))
A
[(1, 'a'), (2, 'b')]
B
[]
C
[(1, 'a')]
Correct answer
D
Error
print(0 or 0)
A
None
B
0
Correct answer
C
False
D
Error
x = 3
print('big' if x > 5 else 'small')
A
big
B
Error
C
None
D
small
Correct answer
print(5 and 0)
A
5
B
0
Correct answer
C
True
D
False
print('' or 'hello')
A
''
B
hello
Correct answer
C
None
D
False
x = 5
print(1
A
False
B
None
C
Error
D
True
Correct answer
i = 0
while i
A
3
Correct answer
B
2
C
4
D
0
print(list(range(2, 8, 2)))
A
[2, 4, 6, 8]
B
[1, 3, 5]
C
[2, 3, 4, 5, 6]
D
[2, 4, 6]
Correct answer
A
Exits the loop
B
Restarts the loop from the first item
C
Ends the function
D
Skips to the next iteration of the loop
Correct answer
A
Skips the current iteration
B
Stops the program
C
Ends a function
D
Exits the nearest enclosing loop
Correct answer
x = 2
match x:
case 1:
print('One')
case 2:
print('Two')
case _:
print('Three')
A
One
B
Three
C
Error
D
Two
Correct answer
for i in range(2):
print(i, end=' ')
else:
print('done')
A
0 1 2 done
B
0 1
C
0 1 done
Correct answer
D
done
print(list(range(5, 0, -1)))
A
[1, 2, 3, 4, 5]
B
[5, 4, 3, 2]
C
[]
D
[5, 4, 3, 2, 1]
Correct answer
Practise on paper
Preparing for Python Interview Control Flow?
Make it your exam plan: see your progress in every subject and topic, set a daily goal and practise what you have not done yet.
Start my Python Interview Control Flow plan
Test yourself
Take a timed online test and get a certificate, or play today's quick quiz.
Online tests
Daily quiz