0% found this document useful (0 votes)
81 views4 pages

Random Function Questions

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

Random Function Questions

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

Random function questions

try to eliminate the incorrect options first.

1. import random
x=random.random( )
y=random.randint(0,4)
print(int(x),”:”,y+int(x))

options:
a) 0:0
b) 1:6
c) 2:4
d) 0:3

2. options will not be expected for the following:


import random
x=3
N=random.randint(1,x)
for i in range(N) :
print(i,’#’,i+1)

options:
a) 0#1
b) 1#2
c) 2#3
d) 3#4
3. import random
AR=[20,30,40,50,60,70]
FROM=random.randint(1,3)
TO=random.randint(2,4)
for k in range(FROM, TO+1):
print(AR[k],end=’#’)

options:
a) 10#40#70#
b) 30#40#50#
c) 50#60#70#
d) 40#50#70#

4. import random
VAL=[80,70,60,50,40,30,20,10]
start=random.randint(1,3)
end=random.randint(start,4)
for i in range(start,end+1):
print(VAL[i],”*”,end=” “)
options :
a) 40*30*20*10*
b) 70*60*50*40*
c) 50*40*30*
d) 60*50*40*30*

5. import random
x=[100,75,10,125]
go=random.randint(0,3)
for i in range(go):
print(x[i],”$$”,end=””)

options:
a) 100$$75$$10
b) 75$$10$$125$$
c) 75$$10$
d) 10$$125$$100

6. import random
play=[40,50,10,20]
round=random.randint(2,3)
for j in range(Round,1,-1):
print(play[j],’:’,end=’ ‘)

options:
a)20:10:
b)20:10:50:
c)20:
d)40:50:20:

7. STRING=”CBSEONLINE”
NUMBER=random.randint(0,3)
N=9
while STRING[N]!=’L’:
print(STRING[N]+STRING[NUMBER)
NUMBER=NUMBER+1
N=N-1

options:
a) ES#NE#IO#
b) LE#NO#ON#
c) NS#IE#LO#
d) EC#NB#IS#

8. import random
NAV=[“LEFT”,”FRONT”,”RIGHT”,”BACK”]
NUM=random.randint(1,3)
NAVG=” “
for I in range(NUM,1,-1)
NAVG=NAVG+NAV[I]
print(NAVG)

options:
a)BACKRIGHT
b)BACKRIGHTFRONT
c)BACK
d)LEFTFRONTRIGHT

9. import random
values=[10,20,30,40,50,60,70,80]
BEGIN=random.randint(1,3)
LAST=random.randint(BEGIN,4)
for I in range (BEGIN,LAST+1):
print(VALUES[I],”-“,end=” “)

options:
a) 30-40-50-
b) 10-20-30-40-
c) 30-40-50-60-
d) 30-40-50-60-70-

10. 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=’@’)

options:

a) 30@
b) 10@20@30@40@50@
c) 20@30@
d) 40@30@

11. import random


PICKER=random.randint(0,3)
city=[“DELHI”,”MUMBAI”,”CHENNAI”,”KOLKATA”]
for I in city:
for J in range(1,PICKER):
print(I,end=’ ‘)
print()

options:
a) DELHIDELHI
MUMBAIMUMBAI
CHENNAICHENNAI
KOLKATAKOLKATA

b) DELHI
MUMBAI
CHENNAI
KOLKATA

c) DELHI
DELHI MUMBAI
DELHI MUMBAI CHENNAI

d) DELHI
MUMBAIMUMBAI
KOLKATAKOLKATAKOLKATA

You might also like