wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Random functions

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

To include the use of functions which are present in the random library, we must use the option:

a)

import random

b)

random.h

c)

import.random

d)

random.random

2.

The output of the above Python code is either 1 or 2.

a)

True

b)

False

c)

error

3.

What will be the output of the above Python code?

a)

An integer other than 2, 3 and 4

b)

Either 2,3 or 4

c)

Error

d)

3 only

4.

What will be the output of above given code

a)

Error

b)

Either 10.4, 56.99 or 76

c)

Any number other than 10.4, 56.99 and 76

d)

56.99 only

5.

What will be the output of the following Python function (random module has already been imported)?


random.choice('sun')

a)

sun

b)

u

c)

either s,u or n

d)

error

6.

What will be the output of the following Python function, assuming that the random module has already been imported?


random.uniform(3,4)

a)

error

b)

either 3 or 4

c)

Any integer other than 3 and 4

d)

Any decimal value between 3 and 4

7.

What will be the output of the following Python function if the random module has already been imported?


random.randint(3.5,7)

a)

Error

b)

Any integer between 3.5 and 7, including 7

c)

Any integer between 3.5 and 7, excluding 7

d)

The integer closest to the mean of 3.5 and 7

8.

randint() takes (a)   arguments

9.

randrange() takes only integer values

a)

True

b)

False

10.

What will be the output of the following Python code?

random.randrange(1,100,10)

a)

32

b)

67

c)

91

d)

80