Code Writer
Level 3, 2026-05-16
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 variable Q. If Q is bigger than 4 print "big", otherwise print "small"
Use: variables, if[2]
|
|
|
Test Using: Q = 0 Q = 5 Q = 10 |
A list contains numbers that are the amount of HP damage caused by a series of attacks. Your character starts with 148HP. 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] |
Do the sum 98 / 54 in code and store the result
Use: variables[1]
|
|
|
|
Assume you have a non-empty list of numbers Y. Write code to find the smallest number in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: Y = [1,2,3] Y = [3,2,1,0] Y = [8,28,20] |
Assume you have a list of numbers F. Write code to count the number of times the number 38 appears in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: F = [38] F = [0,38,-1,38,99,38] F = [10,35,5] |
Assume you have a list of numbers A. Write code to count how many numbers in the list are smaller than or equal to than 12
Use: variables, loops, if[3]
|
|
|
Test Using: A = [] A = [12,0,25] A = [90,19,17] |
Assume you have a variable S that is the length of the side of a square. Calculate another variable that is equal to the area of the square.
Use: variables[2]
|
|
|
Test Using: S = 72 |
|