assign module
assign module
I
SUBJECT-COMPUTERSCIENCE(
083)
ASSI
GNMENTONMODULES
Q1.NamethePythonl
i
brarymoduleswhichneedt
obe
i
mport
edt
oinvokethef
oll
owingfunct
ions:
(
i) cei
l
() (
ii
)randi
nt(
) (
ii
i)f
abs(
) (
iv)mean(
)
2.Wh
Q. atwi
l
lther
angeofv
aluesf
rom gi
venst
atement
s?
i
mportrandom
pr
int
(random.
random(
))
pr
int
(random.
random(
)*5+10)
Q.
3.Wri
tepy
thonstatementtopri
ntthef
oll
owi
ng–
i
-Computesquarerootof1228
i
i
-Compute5.0tothepower3
Q.
4.Consi
derthegivencode-
i
mportrandom
pr
int
(100+random.r
andi
nt(
10,
20)
,end=’
‘)
pr
int
(100+random.r
andi
nt(
10,
20)
,end=’
‘)
pr
int
(100+random.r
andi
nt(
10,
20)
,end=’
‘)
Fi
ndt
hesuggestedout
putf
rom opt
ion(
i)t
o(i
i
i)
(i)110115100
(ii
)112115119
(ii
i)110119120
Q.5.St
udythefol
lowingprogram andsel
ectthepossi
bleout
put
(s)
fr
om theopti
ons(i)t
o(iv)fol
l
owingit.Al
so,wri
tethemaximum and
t
hemi ni
mum v al
uesthatcanbeassignedtothevari
ableY.
i
mpor trandom
X=random.random( )
Y=random.randint(
0,4)
pri
nt(i
nt(X)
,”
:”
,Y+int
(X))
i
)0: 0 i
i
)1:6
i
i
i)2:
4 i
v)0:
3
Q.6.Wri
test
atement
st opri
ntmeanandmedi
anv
aluesofl
i
stwhi
ch
st
oresgi
vennumbers[1,
4,2,
5,
2,
6,
8,3,
2,
7]
Q.7.Dif
fer
enti
atebet
weenther
ound(
)andf
loor
()f
unct
ionswi
tht
he
helpofsui
tabl
eexample.
Q.
8.Di
ff
erent
iat
ebet
weenrandint(
)andr
andr
ange(
)funct
ionby
gi
vi
nganexamplenpossi
bleoutput.
Q9.Fi
ndt heout putofthefoll
owi
ngcode,
alsowr
it
emi
nimum and
maxi
mum v alueofv ari
ablef.
i
mpor trandom
ar=(20,30,40,50,
60,70)
f=random. randint
(1,3)
t=random. randint
(2,4)
forki nrange( f
,t
+1):
print(
ar[k],
end=’#’)
a)
30#40#50#60# b)
30#40#50#
c)
40#50#60#70# d)
40#50#70#
Q.10.Findtheout putofthefoll
owi
ngPy
thoncode,
alsowr
it
emi
nand
maxv al
ueofL.
impor trandom
p=' RLBSCHOOL'
i =0
whi l
ep[i]!='S'
:
L=r andom. r
andi
nt(0,
3)+4
pr i
nt(p[
L],
'-
'
,end='
'
)
i+=1
Out
putOpti
ons:
(
i)O- S-H-
H- (
ii
)C-B-S-
S-
(
ii
i)C-H-S-
O- (
iv)S-
S-H-O-