XII-CS (Ch. 3 Working With Functions ASSIGNMENT-3)
XII-CS (Ch. 3 Working With Functions ASSIGNMENT-3)
Page 1 of 4
m=m+str[i-1]
else:
m=m+"#"
print(m)
Display('[email protected]')
Change(L)
for i in L:
print(i,end='$')
8. Write the output for the execution of the following Python code :
def change(A):
S=0
for i in range(len(A)//2):
S+=(A[i]*2)
return S
B = [10,11,12,30,32,34,35,38,40,2]
Page 2 of 4
C = Change(B)
Print('Output is', C)
A=200
B=20
A= Changer(A,B)
print(A,B,sep='$')
B= Changer(B)
print(A,B,sep='$',end=’###’)
13. Consider the following program, and predict the possible outputs:
import random
string="CBSEONLINE"
number=random. randint (0, 3)
N=9
while string [N] != 'L ' :
print (string [N]+ string [ number]+ '#' , end=' ' )
Page 3 of 4
number=number+1
N=N-1
14. Consider the following program, and predict the possible outputs:
import random
print (100+random. randint ( 5 , 1 0 ) , end=' ' )
print (100+random. randint ( 5 , 1 0 ) , end=' ' )
print (100+random. randint ( 5 , 1 0 ) , end=' ' )
print (100+random. randint ( 5 , 1 0 ) )
a) 102 105 104 105 b) 110 103 104 105 c) 105 107 105 110 d)110 105 105 110
15. What possible output(s) is/are expected to be displayed on the screen at the time of
execution of the program from the following code ? Also specify the maximum and
minimum value that can be assigned to the variable R when K is assigned value as 2.
import random
Signal = [ 'Stop', 'Wait', 'Go' ]
for K in range(2, 0, 1):
R = randrange(K)
print (Signal[R], end = ' # ')
(a) Stop # Wait # Go # (b) Wait # Stop # (c) Go # Wait # (d) Go # Stop #
Page 4 of 4