WorksheetsGITAM HYD FN DAY-2 (19 DEC 23)
Total questions: 31
Worksheet time: 16mins
Name
Class
Date
1.
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
2.
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
3.
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
4.
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
5.
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
6.
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)
error
c)
0 1 2
d)
1 2 0
7.
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
8.
What will be the output of the following Python code?
x = "helloworld"
while i in x:
print(i, end=" ")
a)
h e l l o w o r l d
b)
helloworld
c)
i i i i i i …
d)
error
9.
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
10.
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
11.
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
12.
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
13.
What will be the output of the following Python code?
x = 'word'
for i in x:
print(i.upper())
a)
w o r d
b)
error
c)
w o R D
d)
W O R D
14.
What will be the output of the following Python code?
x = 'tree'
for i in range(len(x)):
print(i)
a)
0 1 2 3
b)
error
c)
t r e e
d)
1 2 3 4
15.
What will be the output of the following Python code snippet?
x = 'free'
for i in range(len(x)):
i.upper()
print (x)
a)
f r e e
b)
0 1 2 3
c)
error
d)
none of the mentioned
16.
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
17.
What will be the output of the following Python code?
x = 786
for i in x:
print(i)
a)
7 8 6
b)
786
c)
error
d)
none of the mentioned
18.
What will be the output of the following Python code?
d = {0: 'a', 1: 'b', 2: 'c'}
for i in d:
print(i)
a)
0 1 2
b)
a b c
c)
none of the mentioned
d)
0 a 1 b 2 c
19.
What will be the output of the following Python code?
d = {0: 'c', 1: 'c', 2: 'c'}
for x, y in d.items():
print(x, y)
a)
0 1 2
b)
0 c 1 c 2 c
c)
ccc
d)
none of the mentioned
20.
What will be the output of the following Python code?
d = {0: 'c', 1: 'c', 2: 'c'}
for x, y in d.keys():
print(x, y)
a)
0 1 2
b)
ccc
c)
0 c 1 c 2 c
d)
none of the mentioned
21.
What will be the output of the following Python code?
d = {0, 1, 2}
for x in d.values():
a)
0 1 2
b)
error
c)
None None None
d)
none of the mentioned
22.
What will be the output of the following Python code?
for i in range(0):
print(i)
a)
0
b)
no output
c)
none
d)
error
23.
What will be the output of the following Python code?
for i in range(2.0):
print(i)
a)
0.0 1.0
b)
0 1
c)
error
d)
none of the mentioned
24.
What will be the output of the following Python code?
for i in range(int(2.0)):
print(i)
a)
0.0 1.0
b)
0 1
c)
error
d)
none of the mentioned
25.
What will be the output of the following Python code?
for i in range(int(float('inf'))):
print (i)
a)
0.0 0.1 0.2 0.3 …
b)
0 1 2 3 …
c)
0.0 1.0 2.0 3.0 …
d)
none of the mentioned
26.
What will be the output of the following Python code snippet?
for i in [2, 0, 2, 3][::-1]:
print(i, end=' ')
a)
no output
b)
error
c)
2 0 2 3
d)
3 2 0 2
27.
What will be the output of the following Python code snippet?
for i in ''.join(reversed(list('abcd'))):
print (i)
a)
d c b a
b)
a b c d
c)
d c b a
d)
error
28.
What will be the output of the following Python code snippet?
x = 10
for i in range(x):
x += 1
print (x)
a)
11 12
b)
0 1 2 3 4 5 6 7 8 9 10
c)
9 8
d)
0 1
29.
What will be the output of the following Python code?
for i in range(5):
if i == 5:
break
else:
print(i)
else:
print("Here")
a)
0 1 2 3 4 Here
b)
0 1 2 3 4 5 Here
c)
1 2 3 4
d)
1 2 3 4 5
30.
What will be the output of the following Python code?
x = (i for i in range(3))
for i in x:
print(i)
for i in x:
print(i)
a)
0 1 2
b)
error
c)
0 1 2 0 1 2
d)
none of the mentioned
31.
What will be the output of the following Python code snippet?
string = "my name is x"
for i in ' '.join(string.split()):
print (i, end=", ")
a)
m, y, , n, a, m, e, , i, s, , x,
b)
my, name, is, x
c)
m, y, n, a, m, e, i, s, x,
d)
error
100 %
