2.3 Random Function Sheet
2.3 Random Function Sheet
Observe the following code carefully then find the correct output
out of option (i) to (iv).
Also write the minimum and maximum value of specified variable.
[1] import random
High=4
Guess = random.randrange(High-1) + 50
for c in range(Guess,56):
print(c,end=’# ’)
(i) 50# 51# 52# 53# 54# 55# (ii) 53# 54#
(iii) 51# 52# 53# 54# 55 (iv) 52# 53# 54# 55#
Find the least and highest value of ‘Guess’.
1
Find minimum and maximum value of Number.
2
[7] import random
Value = random.randrange(2) + 2
Yourtext = *‘ONE’ , ‘TWO’ , ‘SIX’ , ‘TEN’+
for y in range(0,Value):
print(Yourtext*y+ , end=’ ’)
print(‘END’)
(i) ONE TWO END (ii) ONE END TWO END
(iii) ONE TWO SIX (iv) ONE TWO SIX END
Find maximum and minimum value of ‘Value’
3
[10] import random
Low = 25
Point = 5
for i in range(1,5):
Number = Low +random.randrange(Point)
print(Number,end=’ : ‘)
Point = Point-1
(i) 29 : 26 : 25 : 28 : (ii) 24 : 28 : 25 : 26 :
(iii) 29 : 26 : 24 : 28 : (iv) 29 : 26 : 25 : 26 :
Find minimum and maximum value of Number.
4
(ii) 10 EXCEL # 8 OK # 9 GOOD #
(iii) 10 EXCEL # 9 GOOD # 10 EXCEL #
(iv) 10 EXCEL # 10 GOOD # 8 OK #
Find minimum and maximum value of Trick if count is 3.
[13] import random
Game = (10,16)
Turn = random.randrange(2)+5
for T in range(2):
p=random.randrange(2)
print(Game*p++Turn , end = ‘#’)
(i) 15 # 22 # (ii) 22 # 16 #
(iii) 16 # 21 # (iv) 21 # 22 #
Find minimum and maximum value of Turn.
5
DELHI MUMBAI KOLKATA CHHENNAI
(iii) DELHI (iv) MUMBAI
DELHI MUMBAI MUMBAI KOLKATA
DELHI MUMBAI KOLKATA MUMBAI KOLKATA CHENNAI
Find minimum and maximum value of CHANGER.