Worksheetspython-random-rangeLoop
Total questions: 21
Worksheet time: 21mins
What does the random module in python do i.e. import random
Pauses the program for a few seconds
Generates random numbers
Which programming construct is used in specifically in 'For' and 'While' loops?
Sequence
Selection
Iteration
Which of the following is correct?
if colour==blue
if colour=blue:
if colour=="blue":
if color=blue
if you type print("4"+"9") what result would you get
49
13
error
0
To include the use of functions which are present in the random library, we must use the option:
import random
random.h
import.random
random.random
The output of the above Python code is either 1 or 2.
True
False
error
What will be the output of above given code
Error
Either 10.4, 56.99 or 76
Any number other than 10.4, 56.99 and 76
56.99 only
What will be the output of the following Python function (random module has already been imported)?
random.choice('sun')
sun
u
either s,u or n
error
1,2,3,4
#What is the output?
1,2,3,4,5
0,1,2,3,4
1,2,3,4
5,4,3,2,1
#How many hallos will be printed?
5
None
4
6
#What is the output?
a, b, c, d, e
a, a, a, a, a
0,1,2,3,4
e, d, c, b, a
word= "computer"
for num in range(1,6):
print(word)
for number in range(6):
print(number)
Which of the following programs prints ten lines?
for i in range(10):
print("hi")
for i = 1 to 10:
print("hi")
for i in 1 - 10:
print("hi")
for i from 0 to 9:
print("hi")
What would be the output of the following code:
for i in range(3):
print(i)
1 2 3
i i i i
i i i
0 1 2
What would be the output of the following code:
for i in range(3):
print(5)
0 1 2
3 3 3 3 3
5 5 5
0 1 2 3 4
What will this code do?
Print Numbers 1-11
Print Numbers 1-10
Print Numbers 2-10
Print Error
For i in range(6):
print('Happy Python')
How many times Happy Python will be printed?
4
5
6
7
What are the syntax errors in this code?
:
Not indented
Both options
