While Loop In Python: Multiple Choice Questions

While Loop In Python. 14+ Multiple Choice Questions in Python Language on the topic While Loop. 

 

While Loop In Python

 

What will be the output of the following Python code ??

True = False
while True:
print(True)
break

a) True
b) False
c) None
d) none of the mentioned

 

What will be the output of the following Python code ??

i = 1
while False:
if i%2 == 0:
break
print(i)
i += 2

a) 1
b) 1 3 5 7 …
c) 1 2 3 4 …
d) none of the mentioned

 

What will be the output of the following Python code ??

i = 2
while True:
if i%3 == 0:
break
print(i)
i += 2

a) 2 4 6 8 10 …
b) 2 4
c) 2 3
d) error

 

What will be the output of the following Python code ??

i = 1
while True:
if i%2 == 0:
break
print(i)
i += 2

a) 1
b) 1 2
c) 1 2 3 4 5 6 …
d) 1 3 5 7 9 11 …

 

Loop MCQs

 

What will be the output of the following Python code ??

i = 5
while True:
if i%0O9 == 0:
break
print(i)
i += 1

a) 5 6 7 8
b) 5 6 7 8 9
c) 5 6 7 8 9 10 11 12 13 14 15 ….
d) error

 

What will be the output of the following Python code ??

i = 5
while True:
if i%0O11 == 0:
break
print(i)
i += 1

a) 5 6 7 8 9 10
b) 5 6 7 8
c) 5 6
d) error

 

What will be the output of the following Python code ??

i = 1
while True:
if i%0O7 == 0:
break
print(i)
i += 1

a) 1 2 3 4 5 6
b) 1 2 3 4 5 6 7
c) error
d) none of the mentioned

 

What will be the output of the following Python code ??

i = 1
while True:
if i%3 == 0:
break
print(i)
i + = 1

a) 1 2
b) 1 2 3
c) error
d) none of the mentioned

 

While Loop In Python

 

What will be the output of the following Python code ??

x = “abcdef”
i = “a”
while i in x[1:]:
print(i, end = ” “)

a) a a a a a a
b) a
c) no output
d) error

 

What will be the output of the following Python code ??

x = “abcdef”
i = “a”
while i in x:
x = x[1:]
print(i, end = ” “)

a) a a a a a a
b) a
c) no output
d) error

 

What will be the output of the following Python code ??

x = “abcdef”
i = “a”
while i in x[:-1]:
print(i, end = ” “)

a) a a a a a
b) a a a a a a
c) a a a a a a …
d) a

 

What will be the output of the following Python code ??

x = “abcdef”
i = “a”
while i in x:
x = x[:-1]
print(i, end = ” “)

a) i i i i i i
b) a a a a a a
c) a a a a a
d) none of the mentioned

 

While Loop In Python Part

 

What will be the output of the following Python code ??

x = “abcdef”
i = “a”
while i in x:
print(‘i’, end = ” “)

a) no output
b) i i i i i i …
c) a a a a a a …
d) a b c d e f

 

What will be the output of the following Python code ??

x = “abcdef”
i = “a”
while i in x:
print(i, end = ” “)

a) no output
b) i i i i i i …
c) a a a a a a …
d) a b c d e f

 

What will be the output of the following Python code ??

x = “abcdef”
i = “i”
while i in x:
print(i, end=” “)

a) no output
b) i i i i i i …
c) a b c d e f
d) abcdef

 

What will be the output of the following Python code ??

x = “abcdef”
while i in x:
print(i, end=” “)

a) a b c d e f
b) abcdef
c) i i i i i i …
d) error

 

While Loop In Python Part

 

What will be the output of the following Python code ??

i = 0
while i < 3:
print(i)
i += 1
else:
print(0)

a) 0 1 2 3 0
b) 0 1 2 0
c) 0 1 2
d) error

 

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)

a) 0 1 2 0
b) 0 1 2
c) error
d) none of the mentioned

 

Read More

Leave a Comment

Your email address will not be published. Required fields are marked *

error: Content is protected !!