Code Writer
Level 3, 2026-03-06
Answers should be legal Python code, including indentation. Use the underscore _ to show a space.
Special functions: print(), range(), sqrt(), str()
Use a loop to print the average of the numbers from 0 to 8

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

Use: variables, sqrt()[2]
Set two variables to different values then add them together

Use: variables[1]
Use a loop to print the average of the numbers from 0 to 4

Use: variables, loops[2]
Assume you have a non-empty list X. Print the first element in the list.

Use: variables[1]

Test Using:
X = [1]
X = ['b','a','c']
X = [15,67,56]
Use a loop to add the numbers from 1 to 19

Use: variables, loops[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 20!

Use: variables, loops, str()[2]
Assume you have a list variable LIST. Count the number of items in LIST and print the result.

Use: loops, variables[2]

Test Using:
LIST = ['a','b','c']
LIST = [1,2,3,4,5,6]
LIST = []
Set a variable to one value then change that value

Use: variables[1]