Vidyalelo
Python · all questions

Python Loops and Conditionals: MCQs for Exam Readiness
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

91

Questions

3/5

Page

Pick an option on a question to see the right answer and solution.

What will be the output of the following Python code snippet?
for i in '':
    print (i)

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?
for i in 'abcd'[::-1]:
    print (i)

Select an option to see the answer and solution.

What will be the output of the following Python code?
for i in range(2.0):
    print(i)

Select an option to see the answer and solution.

What will be the output of the following Python code?
for i in range(int(2.0)):
    print(i)

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?
for i in ''.join(reversed(list('abcd'))):
    print (i)

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?
x = 2
for i in range(x):
    x += 1
    print (x)

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?
for i in [1, 2, 3, 4][::-1]:
    print (i)

Select an option to see the answer and solution.

What will be the output of the following Python code?
for i in range(float('inf')):
    print (i)

Select an option to see the answer and solution.

What will be the output of the following Python code?
for i in range(int(float('inf'))):
    print (i)

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?
x = 2
for i in range(x):
    x -= 2
    print (x)

Select an option to see the answer and solution.

What will be the output of the following Python code?
x = 123
for i in x:
    print(i)

Select an option to see the answer and solution.

What will be the output of the following Python code?
d = {0, 1, 2}
for x in d:
    print(x)

Select an option to see the answer and solution.

What will be the output of the following Python code?
d = {0, 1, 2}
for x in d.values():
    print(x)

Select an option to see the answer and solution.

What will be the output of the following Python code?
d = {0: 'a', 1: 'b', 2: 'c'}
for i in d:
    print(i)

Select an option to see the answer and solution.

What will be the output of the following Python code?
d = {0: 'a', 1: 'b', 2: 'c'}
for x, y in d.items():
    print(x, y)

Select an option to see the answer and solution.

What will be the output of the following Python code?
d = {0, 1, 2}
for x in d:
    print(d.add(x))

Select an option to see the answer and solution.

What will be the output of the following Python code?
d = {0: 'a', 1: 'b', 2: 'c'}
for x in d.keys():
    print(d[x])

Select an option to see the answer and solution.

What will be the output of the following Python code?
d = {0: 'a', 1: 'b', 2: 'c'}
for x in d.values():
    print(x)

Select an option to see the answer and solution.

What will be the output of the following Python code?
d = {0: 'a', 1: 'b', 2: 'c'}
for x in d.values():
    print(d[x])

Select an option to see the answer and solution.

What will be the output of the following Python code?
d = {0: 'a', 1: 'b', 2: 'c'}
for x, y in d:
    print(x, y)

Select an option to see the answer and solution.