Code Writer
Level 3, 2026-06-26
Answers should be legal Python code, including indentation. Use the underscore _ to show a space.
Special functions: print(), range(), sqrt(), str()
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 18HP

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 = [64,47,53]
A right angled triangle has 2 shorter sides of 9 and 5. Calculate the other side (the "hypotenuse").

Use: variables, sqrt()[2]
Assume you have a variable S that is the length of the side of a square. Calculate another variable that is equal to the area of the square.

Use: variables[2]

Test Using:
S = 41
Assume you have a variable Y. If Y is bigger than 7 print "big", otherwise print "small"

Use: variables, if[2]

Test Using:
Y = 0
Y = 5
Y = 10
Create a list containing 3 numbers and then print each one

Use: variables, loops[2]
Print a list of strings, including a line number on each line

Use: variables, loops, str()[2]
Set a variable to one value then change that value

Use: variables[1]
Do the sum 36 * 94 and print the result

Use: [1]