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 | |
|---|---|---|
| 1for x in range(5) print(x) | AOutput: 6 | |
| 2for in range(5): print('hi') | BOk: Loop through list | |
| 3for char in 'hello': print(char) | CError: Missing colon after for | |
| 4for item in [1, 2, 3]: print(item) | DValid: Loop through string | |
| 5for i in range(3): print(i) | EError: Missing loop variable | |
| 6total = 0 for n in [1,2,3]: total += n print(total) | FOutput: 0 1 2 |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
for — Loop that iterates through each item in a sequence.~~infor i in [1, 2, 3]:
print(i)for i in [1, 2, 3]:
print(i)for char in 'hello':
print(char)for color in ['red', 'blue']:
print(color)for i in range(5):
print(i)