Code Writer
Level 3, 2026-09-18
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 2HP
2 is a medium attack taking 6HP
3 is a strong attack taking 9HP

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 = [87,13,72]
Print your first name

Use: [1]
A right angled triangle has 2 shorter sides of 1 and 7. Calculate the other side (the "hypotenuse").

Use: variables, sqrt()[2]
A factorial of a number is all the numbers from 1 to that number multiplied together, so 4! = 1x2x3x4. Write code using a loop to calculate 45!

Use: variables, loops, str()[2]
Assume you have a list E with at least 2 elements. Create a new variable that is equal to the first two elements added together.

Use: variables[1]

Test Using:
E = ['a','b','c']
E = ['big','dog']
E = [47,86,17]
Do the sum 21 + 27 in code and store the result

Use: variables[1]
Assume you have a list variable LIST of numbers. Use a variable to add the items in the list

Use: variables, loops[2]

Test Using:
LIST = [1]
LIST = [1,2,3,4,5,6,7,8,9]
LIST = [22,92,15]
Print each number from 1 to 38

Use: loops[2]
Set a variable to one value then change that value

Use: variables[1]