Output Based Questions
Output Based Questions
14. Which of the following option can be the output for the following Python code?
L1 = [10,20,30,40,50]
L2= [ ]
for i in L1:
if i not in L2:
L2.append(i)
print (L1, L2, sep=”&”)
17. What possible output(s) will be obtained when the following code is executed? Also write
the minimum and maximum values of Low and High.
Import random as ran
Low=2+ran.randint(1,3)
High=5+ran.randint(0,3)
C=”ABCDEFGHIJ”
for I in range(Low,High):
print(C[I],end=” “)
25. What possible output(s) will be obtained when the following code is executed?
Import random
myNumber = random.randint(0,3)
COLOR=[“YELLOW”,”WHITE”,”BLACK”,”RED”]
for I in COLOR:
for j in range (1,mynumber):
print(I, end = “ “)
print ()
26. Write the output as well as the number of times the loop runs?
s="cbse"
a=0
for x in s[3:8]:
print(x)
a+=1
print(a)
27. Predict the output of the following code:
def Changer(P,Q=10):
P=P/Q
Q=P%Q
return P
A=200
B=20
A=Changer(A,B)
print(A,B,sep=”$”)
B=Changer(B)
print(A,B,sep=”$”,end=”###”)
28.
29.
30.