Professional Documents
Culture Documents
4 - Questions of For Loop
4 - Questions of For Loop
1
By – Prabin K Rout mob:9861693445 fb:facebook.com/prabinlit insta:prabin_k_rout
4– Question of For Loop Python # By- Prabin K Rout
13. What will be the output of the following 18. For loop can work with iterable objects ?
Python list comprehension?
import math True False
[str(round(math.pi)) for i in range (1, 6)] 19. For loop head will execute how many times ?
[4, 8, 12, 5, 10, 15, 6, 12, 18] 23. What is the default start for range object ?
[4, 10, 18]
[4, 5, 6, 8, 10, 12, 12, 15, 18] 0 1
[18, 12, 6, 15, 10, 5, 12, 8, 4] -1 2
16. What will be the output of the following 24. Can we provide float value in start, stop and
Python list comprehension? step for range object ?
num_list = [y for y in range(100) if y % 2 == 0 if y % Yes No
5 == 0]
print( num_list ) 25. What is the output of the following?
x = 'abcd'
A list of all even number for i in range(len(x)):
[0, 10, 20, 30, 40, 50, 60, 70, 80, 90] x[i].upper()
Error print (x)
none of the mentioned
abcd ABCD
17. How many times the following python program error none of the mentioned
will execute ? 26. What is the output of the following?
listObj = [ 'a', 'b', 'c'] x = 'abcd'
for data in listObj : for i in x:
listObj . append ( data . upper () ) print(i.upper())
3 0 abcd ABCD
Error Infinite aBCD Error
2
By – Prabin K Rout mob:9861693445 fb:facebook.com/prabinlit insta:prabin_k_rout
4– Question of For Loop Python # By- Prabin K Rout
27. What is the output of the following? 31. What will be the output of the following
d = {0: 'a', 1: 'b', 2: 'c'} Python code?
for x in d.values(): x = (i for i in range(3))
print(x) for i in x:
print(i)
012 abc for i in x:
0 a 1b 2 c none of the mentioned print(i)
12345 2 0
4 3
30. What will be the output of the following 34. What will be the output of the following
Python code? Python code?
x = (i for i in range(3)) list1 = [3,2,5,6,0,7,9]
for i in x: sum=0
print(i) sum1=0
for elem in list1:
012 if elem %2==0:
sum = sum+elem
error continue
if elem %3==0:
012012 sum1 = sum1+elem
print(sum ,end=' ')
none of the mentioned print(sum1)
89 83
3
By – Prabin K Rout mob:9861693445 fb:facebook.com/prabinlit insta:prabin_k_rout
4– Question of For Loop Python # By- Prabin K Rout
23 8 12
012 None None None None
35. what is the output of following? Error none of the mentioned
for i in [1, 2, 3, 4][ : : -1]:
print ( i ) 40. What will be the output of the following
Python code?
1234 d = {0, 1, 2}
4321 for x in d:
Error print(x)
none of the mentioned
012
36. what is the output of following?
x= ['ab', 'cd'] {0, 1, 2} {0, 1, 2} {0, 1, 2}
for i in x :
i.upper() Error
print ( x )
none of the mentioned
none of the mentioned
[None, None] 41. What will be the output of the following
['AB', 'CD'] Python code?
['ab', 'cd'] d = {0, 1, 2}
for x in d:
37. What will be the output of the following print(d.add(x))
Python code?
x = 123 012
for i in x:
print(i) 012012012…
39. What will be the output of the following none of the mentioned
Python code?
d = {0, 1, 2}
for x in d.values():
print(x)
4
By – Prabin K Rout mob:9861693445 fb:facebook.com/prabinlit insta:prabin_k_rout