0% found this document useful (0 votes)
35 views6 pages

2.3 Random Function Sheet

The document presents a series of Python code snippets that utilize the random module to generate various outputs based on random values. Each code segment is followed by multiple-choice options for the expected output, along with requests to determine the minimum and maximum values of specific variables used in the code. The document serves as a programming exercise to test understanding of random number generation and output formatting in Python.

Uploaded by

mishrarajesh1541
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views6 pages

2.3 Random Function Sheet

The document presents a series of Python code snippets that utilize the random module to generate various outputs based on random values. Each code segment is followed by multiple-choice options for the expected output, along with requests to determine the minimum and maximum values of specific variables used in the code. The document serves as a programming exercise to test understanding of random number generation and output formatting in Python.

Uploaded by

mishrarajesh1541
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

OUTPUT SHEET OF RANDOM FUNCTION

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’.

[2] import random


Max=5
MyNum = 20 + random.randrange(Max)
for N in range(MyNum,26):
print(N,end=’ * ‘)
(i) 20 * 21 * 22 * 23 * 24 * 25 (ii) 22 * 23 * 24 * 25 *
(iii) 23 * 24 * (iv) 21 * 22 * 23 * 24 * 25
Find the minimum and maximum value of MyNum.

[3] import random


Low = 15
Point = 5
for I in range(1,5):
Number = Low + random.randrange(Point)
print(Number, end = ’ : ’)
Point=Point-1
(i) 19 : 16 : 15 : 18 : (ii) 14 : 18 : 15 : 16 :
(iii) 19 : 16 : 14 : 18 : (iv) 19 : 16 : 15 : 16 :

1
Find minimum and maximum value of Number.

[4] import random


Begin = 3
for Run in range(1,4):
stop = random.randrange(Begin) + 6
print(Begin , stop , end=’ * ‘)
Begin = Begin + 1
(i) 36 * 46 * 59* (ii) 37 * 46 * 56 *
(iii) 37 * 48 * 57 * (iv) 35 * 45 * 57 *
Find maximum and minimum value of stop.

[5] import random


limit = 4
points = 100 + random.randrange(limit)
for p in range(points,99,-1):
print(p,end='#')
(i) 103 # 102 # 101 # 100 #
(ii) 100 # 101 # 102 # 103 #
(iii) 100 # 101 # 102 # 103 # 104 #
(iv) 104 # 103 # 102 # 101 # 100 #
Find minimum and maximum value of Points

[6] import random


Guess = [200,150,20,250]
Start = random.randint(0,1) + 2
For c in range(Start,4):
print(Guess*c+,end=’#’)
(i) 200 # 150 # (ii) 150 # 20 #
(iii) 150 # 20 # 250 # (iv) 20 # 250 #
Find minimum and maximum value of Start.

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’

[8] import random


GuessMe = (100,50,200,20)
Taker = random.randrange(2) + 2
for Chance in range(Taker):
print(GuessMe*Chance+,end=’ # ’)
(i) 100 (ii) 50#200# (iii) 100#50 (iv) 100#50#200
Find least and highest vales of Taker.

[9] import random


Max = 3
Number = 50 +random.randrange(Max)
for p in range(Number,49,-1):
print(p , ’#’ , end=’ ’)
(i) 53 # 52 # 51 # 50 (ii) 50 # 51 # 52 #
(iii) 50 # 51 # (iv) 51 # 50 #
Find minimum and maximum value of ‘Number’.

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.

[11] import random


Result = *‘Gold’, ’Silver’, ’Bronze’+
Getit = 9
for Turn in range(1,4):
Guess = random.randrange(Turn)
print(Getit – Guess, Result*Guess+, end = ‘ * ’ )
(i) 9 GOLD * 9 GOLD * 8 SILVER *
(ii) 9 GOLD * 7 BRONZE * 8 GOLD *
(iii) 9 GOLD * 8 SILVER * 9 GOLD *
(iv) 9 GOLD * 8 SILVER * 8 GOLD *
Find minimum and maximum value of ‘Guess’ if turn is 3.

[12] import random


Status = *‘EXCEL’,’GOOD’,’OK’+
Turn = 10
For count in range(1,4):
Trick = random.randrange(count)
print(Turn – Trick , status*Trick+,end=’#’)
(i) 10 EXCEL # 10 EXCEL # 8 OK #

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.

[14] import random


Arr = (9,6)
Chance = random.randrange(2) + 10
for c in range(2):
n = random.randrange(2)
print(Arr*n+ + Chance, end=’#’)
(i) 9 # 6 # (ii) 19 # 17 #
(iii) 19 # 16 # (iv) 20 # 16 #
Find minimum and maximum value of Chance.

[15] import random


CHANGER = random.randrange(3)
CITY = *‘DELHI’,’MUMBAI’,’KOLKATA’,’CHENNAI’+
for i in range(CHANGER+1):
for j in range(i +1):
print(CITY*j+,end=’ ’)
print()
(i) DELHI (ii) KOLKATA
DELHI MUMBAI KOLKATA CHENNAI
DELHI MUMBAI KOLKATA

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.

[16] import random


Picker = 1 + random.randrange(3)
Colour = *‘BLUE’,’PINK’,’GREEN’,’RED’+
for i in range(Picker +1):
for j in range( i +1):
print(Colour*j+ , end=’ ‘)
print()
(i) PINK (ii) BLUE
PINK GREEN BLUE PINK
PINK GREEN RED BLUE PINK GREEN
(iii) BLUE (iv) GREEN
BLUE PINK GREEN RED
BLUE PINK GREEN
BLUE PINK GREEN RED
Find maximum and minimum value of Picker.

[17] import random


NUM = random.randrange(3) + 2
TEXT = ‘ABCDEFGHIJK’
for i in range(1,NUM+1):
for j in range(num , 8):
print(TEXT*j+ , end=’ ‘)
print()
(i) BCDEFGH (ii) FGHI (iii) EFGH (iv) CDEFGH
BCDEFGH FGHI EFGH CDEFGH
FGHI EFGH
FGHI EFGH
Find maximum and minimum value of NUM.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy