wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Randomness and Libraries 2.5 Python

Total questions: 13

Worksheet time: 7mins

Name
Class
Date
1.

What is a library in coding?

a)

Place to store the code you have written

b)

Collection of code from outside of the program

c)

Location to find books to help you learn coding

d)

The list of examples for coding

2.

What is the pygame library used for?

a)

Used to create randomness in your python code

b)

Used to create graphics for your graphical games

c)

Used to find errors in your code

d)

Used to add sound to your code

3.

What is the random library used for?

a)

Used to find errors in your code

b)

Used to add sound to your code

c)

Used to add graphics to your code

d)

Used to add randomness to your code

4.

Which is the correct statement to use the random library in your program?

a)

import random

b)

random import

c)

random.randint( )

d)

random = import

5.

random.randint(min,max)

a)

Forces a certain number to print every time

b)

Gives you a random integer within the minimum and maximum set values when you run the program

c)

Gives you random numbers outside of the minimum and maximum set values

d)

Will create an error message

6.

random.choice(list) chooses a random value from a list

a)

True

b)

False

7.

random.shuffle(list) arranges the list in a random order

a)

True

b)

False

8.

What is a function?

a)

an action within your code, print and input are examples of functions

b)

an action defined in one location but used somewhere else in your code, print and input are examples of functions

9.

Which is an example of a function call?

a)

input( )

b)

input:

c)

input" "

d)

input,

10.

You call a function by

a)

typing in its name followed by open and closed parenthesis

b)

typing import

c)

Using a colon at the end of a line of code

d)

typing random.randint(min, max)

11.

Pieces of information that you need to give a function in order for it to run.

a)

Data

b)

Function

c)

Argument

d)

Editor

12.

What does the Dot Operator do?

a)

has no meaning in the coding environment

b)

is used when making a list

c)

is needed to end the line of code

d)

lets us look inside a library to find a function

13.

How many arguments does randint need?

random.randint(min, max)

a)

1

b)

2

c)

3

d)

4