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

4/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?
for i in range(0):
    print(i)

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What will be the output of the following Python code?
x = 'abcd'
for i in x:
    print(i.upper())

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?
x = 'abcd'
for i in range(len(x)):
    print(x)
    x = 'a'

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?
x = 'abcd'
for i in range(len(x)):
    i.upper()
print (x)

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?
x = 'abcd'
for i in range(len(x)):
    x[i].upper()
print (x)

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?
x = 'abcd'
for i in range(len(x)):
    i[x].upper()
print (x)

Select an option to see the answer and solution.

What will be the output of the following Python code?
x = 'abcd'
for i in range(len(x)):
    print(i.upper())

Select an option to see the answer and solution.

What will be the output of the following Python code?
x = 'abcd'
for i in x:
    print(i)
    x.upper()

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?
x = 'abcd'
for i in range(len(x)):
    x = 'a'
    print(x)

Select an option to see the answer and solution.

What will be the output of the following Python code?
x = 'abcd'
for i in range(len(x)):
    print(i)

Select an option to see the answer and solution.

What will be the output of the following Python code?
x = "abcdef"
while i in x:
    print(i, end=" ")

Select an option to see the answer and solution.

What will be the output of the following Python code?
x = "abcdef"
i = "a"
while i in x:
    x = x[1:]
    print(i, end = " ")

Select an option to see the answer and solution.

What will be the output of the following Python code?
x = "abcdef"
i = "a"
while i in x[1:]:
    print(i, end = " ")

Select an option to see the answer and solution.

What will be the output of the following Python code?
x = "abcdef"
i = "i"
while i in x:
    print(i, end=" ")

Select an option to see the answer and solution.

What will be the output of the following Python code?
x = "abcdef"
i = "a"
while i in x:
    x = x[:-1]
    print(i, end = " ")

Select an option to see the answer and solution.

What will be the output of the following Python code?
x = "abcdef"
i = "a"
while i in x[:-1]:
    print(i, end = " ")

Select an option to see the answer and solution.

What will be the output of the following Python code?
i = 0
while i < 3:
    print(i)
    i += 1
else:
    print(0)

Select an option to see the answer and solution.

What will be the output of the following Python code?
i = 0
while i < 5:
    print(i)
    i += 1
    if i == 3:
        break
else:
    print(0)

Select an option to see the answer and solution.

What will be the output of the following Python code?
x = "abcdef"
i = "a"
while i in x:
    print(i, end = " ")

Select an option to see the answer and solution.