Random module WS 1
Random module WS 1
import random
VALUES = [10, 20, 30, 40, 50, 60, 70, 80]
BEGIN = random.randint (1, 3)
LAST = random.randint(2, 4)
for I in range (BEGIN, LAST+1):
print (VALUES[I], end = " - ")
(i) 30-40-50-
(ii) 10-20-30-40-
(iii) 30-40-50-60-
(iv) 30-40-50-60-70-
(i)10#40#70#
(ii)30#40#50#
(iii)50#60#70#
(iv)40#50#70#
What could be the possible outputs out of the given four choices?
i) 2 3 4
ii) 9 4 4
iii)16 16 16
iv)2 4 9
10. Consider the following code and find out the possible output(s) from
the options given below. Also write the least and highest value that can be
generated.
import random as r
print(10 + r.randint(10,15) ,end = ‘ ‘)
print(10 + r.randint(10,15) , end = ‘ ‘)
print(10 + r.randint(10,15) , end = ‘ ‘)
print(10 + r.randint(10,15))
i) 25 25 25 21
iii) 23 22 25 20
ii) 23 27 22 20
iv) 21 25 20 24
import random
heights=[10,20,30,40,50]
beg=random.randint(0,2)
end=random.randint(2,4)
for x in range(beg,end):
print(heights[x],end=’@’)
(a)30 @
(b) 10@20@30@40@50@
(c) 20@30
(d) 40@30@
import random
STRING="CBSEONLINE"
NUMBER = random.randint (0, 3)
N=9
while STRING[N] != "L":
print (STRING[N] + STRING[NUMBER] + "#", end = " ")
NUMBER = NUMBER +1
N=N-1