For Loop In Python: Multiple Choice Questions

For Loop In Python Part 1. Multiple Choice Questions in Python Language on the topic Foor Loop.

 

For Loop In Python Part 1

 

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

x = ‘abcd’
for i in range(len(x)):
print(x)
x = ‘a’

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

 

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

x = ‘abcd’
for i in range(len(x)):
x = ‘a’
print(x)

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

 

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

x = ‘abcd’
for i in range(len(x)):
i[x].upper()
print (x)

a) abcd
b) ABCD
c) error
d) none of the mentioned

 

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

x = ‘abcd’
for i in range(len(x)):
x[i].upper()
print (x)

a) abcd
b) ABCD
c) error
d) none of the mentioned

 

For Loop In Python Part 1

 

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

x = ‘abcd’
for i in range(len(x)):
i.upper()
print (x)

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

 

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

x = ‘abcd’
for i in range(len(x)):
print(i.upper())

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

 

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

x = ‘abcd’
for i in range(len(x)):
print(i)

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

 

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

x = ‘abcd’
for i in range(x):
print(i)

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

 

For Loop In Python Part 1

 

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

x = ‘abcd’
for i in x:
print(i.upper())

a) a b c d
b) A B C D
c) a B C D
d) error

 

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

x = ‘abcd’
for i in x:
print(i)
x.upper()

a) a B C D
b) a b c d
c) A B C D
d) error

 

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

x = [‘ab’, ‘cd’]
for i in x:
x.append(i.upper())
print(x)

a) [‘AB’, ‘CD’]
b) [‘ab’, ‘cd’, ‘AB’, ‘CD’]
c) [‘ab’, ‘cd’]
d) none of the mentioned

 

 

What will be the output of the following Python code?

x = [‘ab’, ‘cd’]
for i in x:
i.upper()
print(x)

a) [‘ab’, ‘cd’]
b) [‘AB’, ‘CD’]
c) [None, None]
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 !!