Code Writer
Level 3, 2026-08-16
Answers should be legal Python code, including indentation. Use the underscore _ to show a space.
Special functions: print(), range(), sqrt(), str()
Set a variable to one value then change that value
Use: variables[1]
|
|
|
|
A list contains numbers that are the amount of HP damage caused by a series of attacks. Your character starts with 142HP. Write code that works out how much damage you have taken and prints "Dead" if you are killed.
Use: variables, loops, if[3]
|
|
|
Test Using: attacks = [1] attacks = [50,50,50] attacks = [1,1,1] |
Print a list of strings, including a line number on each line
Use: variables, loops, str()[2]
|
|
|
|
Assume you have a list of numbers Z. Create a new variable that is equal to sum of all the numbers in Z.
Use: variables, loops[2]
|
|
|
Test Using: Z = [] Z = [1,1] Z = [50,79,10] |
Use a loop to add the numbers from 0 to 27
Use: variables, loops[2]
|
|
|
|
Create a list containing 5 numbers and then print each one
Use: variables, loops[2]
|
|
|
|
Assume you have a variable Z. If Z is smaller than 3 add 6 to it, otherwise subtract 5 from it
Use: variables, if[2]
|
|
|
Test Using: Z = 0 Z = 3 Z = 10 |
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 = [18,85,0] |
|