VELAMMAL VIDYALAYA ALAPAKKAM
PYTHON LIBRARIES
i) PREDICT THE OUTPUT
Study the following program and select the possible output(s) and write
maximum and minimum value assigned to the variable y
import random
x=[Link]( )
y=[Link](0,4)
print(int(x),”:”,y+int(x))
(i) 0:0 (ii) 1: 6 (iii) 2:4 (iv) 0:3 ans : i and iv
[Link] possible output(s) are expected to be displayed on screen at the
time of execution of the following code? Also specify the maximum and
minimum value that can be assigned to variable X.
import random
L=[10,7,21]
X=[Link](1,2)
for i in range(X):
Y=[Link](1,X)
print(L[Y],”$”,end=” ”)
(a) 10 $ 7 $ (b) 21 $ 7 $ (c) 21 $ 10 $ (d) 7 $ ans : b and d
3. Give the output of the following code:
>>>import math
>>>[Link](1.03)+[Link](1.03)
a) 3
b) -3.0
c) 3.0
d) None of the above ans : a
[Link] possible outputs are expected to be displayed on screen at the
time of execution of the program from the following code? Also
specify the maximum value that can be assigned to each of the
variables L and U.
import random
Arr=[10,30,40,50,70,90,100]
L=[Link](1,3)
U=[Link](3,6)
for i in range(L,U+1):
print(Arr[i],"@",end="")
(i) 40 @50 @ (ii) 10 @50 @70 @90 @
(iii) 40 @50 @70 @90 @ (iv) 40 @100 @ ans : i and iii
[Link] of the following is not a function/method of the random module
in python?
(a) randfloat( ) (b) randint( ) (c) random( ) (d) randrange( ) ans : a
[Link] are the incorrect output(s) from the given options when the
Following code is executed? Also specify the minimum and maximum
values that can be assigned to the variable VALUE.
import random
VALUE = [Link] (0,3)
SUBJECT=[“PHY”,”CHEM”,”MATHS”,”COMP”];
for I in SUBJECT:
for J in range(1, VALUE):
print(I, end=””)
print()
i) PHYPHY
CHEMCHEM
MATHSMATHS
COMPCOMP
ii) PHY
PHYCHEM
PHYCHEMMATHS
iii) PHY
CHEMCHEM
COMPCOMPCOMP
iv) PHY
CHEM
MATHS
COMP ans : i and iv
[Link] through the python code shown below and find out the possible
output(s) from the suggested options i to iv. Also specify maximum and
minimum value that can be assigned to the variable j.
import random
i=[Link]()
j=[Link](0,6)
print(int(i),”:”,j+int(i))
(i)0:0 (ii)0:6 (iii)1:7 (iv)1:6 ans : i and ii
[Link] possible output(s) are expected to be displayed on screen at the
time of
execution of the program from the following code? Also write the value
assigned to variable first and second.
from random import randint
LST=[5,10,15,20,25,30,35,40,45,50,60,70]
first = [Link](3,8) – 1
second = [Link](4,9) – 2
third = [Link](6,11) – 3
print(LST[first],"#", LST[second],"#", LST[third],"#")
i) 20#25#25#
ii) 30#40#70#
iii) 15#60#70# ans : a
iv) 35#40#60#
9. 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 = [Link](K)
print (Signal[R], end = ' # ')
(a) Stop # Wait # Go #
(b) Wait # Stop #
(c) Go # Wait #
(d) Go # Stop # ans : b
[Link] random
for n in range(2,5,2):
print([Link](1,n,end=‟*‟)
(a)1*3 (b) 2*3 (c) 1*3*4 (d)1*4 ans : a
[Link] the Python library module needed to be imported to invoke
following functions:
a. floor ( )
b. randint ( ) ans : math and random
12..Define module,library,package
[Link] are the two ways to import modules in python program?
[Link] math module WAP to calculate the power of the given numbers.
[Link] to choose 3 students out of 100 students randomly
[Link] is the use divmod(),min(),max(),sum(),oct(),hex() with an
example.