PYTHON LIBRARIES
WORKSHEET
1)What possible outcome will be produced when the following code is executed? import random
value=[Link](0,3) fruit=["APPLE","ORANGE","MANGO","GRAPE"]
for i in range(value): print(fruit[i],end='##')
print()
a) APPLE##
b) APPLE# ORANGE##
c) APPLE## ORANGE##
d) ORANGE## MANGO## APPLE##
2) What possible output(s) will be obtained when the following code is executed
import random
k=[Link](1,3)
fruits=[‘mango’, ‘banana’, ‘grapes’, ‘water melon’, ‘papaya’] for j in
range(k):
print(j, end=“*”)
(a) mango*banana*grapes (b) banana*grapes
(c) banana*grapes*watermelon (d) mango*grapes*papaya
3) Find possible o/p (s) at the time of execution of the program from the following code?
Also specify the maximum values of variables Lower and Upper.
import random as r
AR=[20, 30, 40, 50, 60,
70];
Lower=[Link](1,3)
Upper
=[Link](2,4)
for K in range(Lower, Upper +1):
print (AR[K],end=”#“)
(i) 10#40#70# (ii) 30#40#50#
(iii) 50#60#70# (iv) 40#50#70#
4) What possible outputs(s) are expected to be displayed on screen at the time of execution of
the program from the following code? Also specify the maximum values that can be assigned
to each of the variables FROM and TO.
import random
AR=[20,30,40,50,60,70]
FROM=[Link](1,3)
TO=[Link](2,4)
for K in range(FROM,TO): print
(AR[K],end=”#“)
(i)10#40#70# (ii)30#40#50# (iii)50#60#70# (iv)40#50#70#
ii)30#40#50#
Maximum value assigned to FROM is 3
Maximum value assigned to TO is 4
5) Identify the correct output(s) of the following code. Also write the minimum and
the maximum possible values of the variable b.
import random
text = "Adventure"
b = [Link](1, 5)
for i in range(0, b):
print(text[i], end='*')
(A) A* (B) A*D*
(C) A*d*v* (D) A*d*v*e*n*t*u*
Ans : Minimum possible value of b: 1
Maximum possible value of b: 5
Possible Outputs : (A) and ( C )
6) Identify the correct output(s) of the following code. Also write the minimum and the
maximum possible values of the variable Lot
import random word='Inspiration'
Lot=2*[Link](2,4)
for i in range(Lot,len(word),3):
print(word[i],end='$')
i) i$a$i$n$ ii) i$n$
iii) i$t$n$ iv) a$i$n$
Minimum value possible for Lot: 4 Maximum value possible for Lot: 8 Possible outputs are :
i) and ii)
7) Identify the correct output(s) of the following code and write the minimum and the
maximum possible values of the variable b.
import random a="ComputerScience"
I=0
while (I<3):
b=[Link](1,len(a)-1) print(a[b],end='$')
I+=2
A) C$m$ B) m$p$ C) c$n$ D)c$e$c$
Answer : B) m$p$ C) c$n$
8) Identify the correct output(s) of the following code (Select from A - D). Also write the
minimum and the maximum possible values of the variable b.
import random
Lang = ['Python', 'Ruby', 'JAVA', 'Pascal']
b=[Link](0,3)
for i in range(b):
print(Lang[i][i],'*',end=" ")
A. P * u * V *
B. P * R *
C. u * A * P*
D. P *
9. What will be output of the following code? Also, state the maximum and minimum
possible values for the variable b?
import random
b=[Link](3,8) 3 A 5b7 8
for i in range(0,b,3):
print(a[i], end =*)
a) P*o* b) P*g* c) P*g d) P*g*m*
10. import random
AR=[20,30,40,50,60,70]
FROM=[Link](1,3)
TO=[Link](2,4)
for K in range(FROM,TO+1):
print(AR[K],end=”#“ )
(i)10#40#70# (ii)30#40#50# (iii)50#60#70# (iv)40#50#70#
10 . Write the possible outputs(s) when this code is executed?
import random
n=[Link](0,3)
color=[“Y”,”W”,”B”,”R”]
for i in range (1,n):
print(color[i], end=”*”)
print( )
a) R * b) W*
W* B*
B*
c) W* W* d) Y*
B* B* W* W*
B* B* B*
11) What possible outputs(s) will be obtained when the following code is
executed?
import random
Signal=['Stop','Wait','Go']
for K in range (2,0,-1):
R=[Link](K)
print(Signal[R], end='#')
options:
a. Stop#Go#
b. Wait#Stop#
c. Go#Stop#
d. Go#Wait#