Code Writer
Level 3, 2026-10-27
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 of numbers Z. Write code to find the biggest number in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: Z = [1,2,3] Z = [3,2,1,0] Z = [31,40,67] |
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 = [] |
A right angled triangle has a hypotenuse (longest side, opposite the right angle) of 9 and another side of 6. Calculate the length of the missing side.
Use: variables, sqrt()[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 15HP
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 = [99,68,1] |
Do the sum 90 / 49 in code and store the result
Use: variables[1]
|
|
|
|
Assume you have a variable VAR. If VAR is bigger than 8 print "big", otherwise print "small"
Use: variables, if[2]
|
|
|
Test Using: VAR = 0 VAR = 5 VAR = 10 |
Print each number from 0 to 23
Use: loops[2]
|
|
|
|
Assume you have 2 lists of numbers with 16 elements each: Y and VAR. Add the 8th elements of the lists together.
Use: variables[1]
|
|
|
Test Using: Y = [1,2,3,...,16], VAR = [1,2,3,...,16] |
|