NEW
Font size
WorksheetsRandomness and Libraries 2.5 Python
Total questions: 13
Worksheet time: 7mins
What is a library in coding?
Place to store the code you have written
Collection of code from outside of the program
Location to find books to help you learn coding
The list of examples for coding
What is the pygame library used for?
Used to create randomness in your python code
Used to create graphics for your graphical games
Used to find errors in your code
Used to add sound to your code
What is the random library used for?
Used to find errors in your code
Used to add sound to your code
Used to add graphics to your code
Used to add randomness to your code
Which is the correct statement to use the random library in your program?
import random
random import
random.randint( )
random = import
random.randint(min,max)
Forces a certain number to print every time
Gives you a random integer within the minimum and maximum set values when you run the program
Gives you random numbers outside of the minimum and maximum set values
Will create an error message
random.choice(list) chooses a random value from a list
True
False
random.shuffle(list) arranges the list in a random order
True
False
What is a function?
an action within your code, print and input are examples of functions
an action defined in one location but used somewhere else in your code, print and input are examples of functions
Which is an example of a function call?
input( )
input:
input" "
input,
You call a function by
typing in its name followed by open and closed parenthesis
typing import
Using a colon at the end of a line of code
typing random.randint(min, max)
Pieces of information that you need to give a function in order for it to run.
Data
Function
Argument
Editor
What does the Dot Operator do?
has no meaning in the coding environment
is used when making a list
is needed to end the line of code
lets us look inside a library to find a function
How many arguments does randint need?
random.randint(min, max)
1
2
3
4
