Code Writer
Level 3, 2026-04-13
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 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 = [] |
Do the sum 55 - 95 in code and store the result
Use: variables[1]
|
|
|
|
Create two strings and join them together with a space between
Use: variables[1]
|
|
|
|
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 4HP 3 is a strong attack taking 13HP
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 = [95,86,48] |
Assume you have a variable A. If A is bigger than 4 print "big", otherwise print "small"
Use: variables, if[2]
|
|
|
Test Using: A = 0 A = 5 A = 10 |
A right angled triangle has a hypotenuse (longest side, opposite the right angle) of 11 and another side of 7. Calculate the length of the missing side.
Use: variables, sqrt()[2]
|
|
|
|
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 = [36,83,16] |
Use a loop to create a string that has 36 "g" characters
Use: variables, loops[2]
|
|
|
|
|