Code Writer
Level 3, 2026-06-15
Answers should be legal Python code, including indentation. Use the underscore _ to show a space.
Special functions: print(), range(), sqrt(), str()
Assume you have a non-empty list Z. Print the first element in the list.

Use: variables[1]

Test Using:
Z = [1]
Z = ['b','a','c']
Z = [82,71,66]
Print each number from 1 to 20

Use: loops[2]
Assume you have two non-empty lists of numbers F and Z. Create a new variable that is equal to the first element of each list added together.

Use: variables[1]

Test Using:
F = [1], Z = [1]
F = [1,2,3], Z = [3,2,1]
F = [20,61,1], Z = [93,12,24]
A right angled triangle has a hypotenuse (longest side, opposite the right angle) of 11 and another side of 1. Calculate the length of the missing side.

Use: variables, sqrt()[2]
Print each number from 1 to 13

Use: loops[2]
A list contains a series of attacks on an enemy. The list looks like [1,2,3,1,1,2,...] where each element in the list is a number that means a type of attack:

1 is a light attack, taking 1HP
2 is a medium attack taking 5HP
3 is a strong attack taking 16HP

Write code to calculate the total amount of HP damage caused by all the attacks.

Use: variables, loops, if[3]

Test Using:
attacks = [1,2,3]
attacks = [1,2,3,3,2,1]
attacks = [13,28,21]
Use a loop to print the average of the numbers from 3 to 17

Use: variables, loops[2]
Assume you have a list variable LIST. Print each value in LIST.

Use: loops[2]

Test Using:
LIST = [1,2,3]
LIST = ['a','b',0]
LIST = []