Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1import random | Aroll = random.randint(1, 6) | |
| 2random.randint(1, 6) | Brandint is called without random. in front. It should be random.randint(1, 10). | |
| 3Roll a dice and save the random whole number from 1 to 6 in a variable | CGives your program the random module so you can use random.randint() and random.choice() | |
| 4Pick a random item from a list of snacks | DThe import random line is missing, so Python does not know what random is and shows a NameError. Add import random at the top. | |
| 5num = random.randint(1, 10) (no import random line at the top) | Erandom.choice(snacks) | |
| 6import random num = randint(1, 10) | FGives a random whole number from 1 to 6, including both 1 and 6 |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
import random — Gives your program the random module. Then random.randint(1, 6) gives a random whole number from 1 to 6, and random.choice(my_list) picks a random item from a list.import randomimport randomroll = random.randint(1, 6)roll = random.randint(1, 6)pick = random.choice(colours)