Code Writer
Level 3, 2026-11-24
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 scores E for your math class. Calculate the mean of the scores.
Use: variables, loops[3]
|
|
|
Test Using: E = [10] E = [1,2,3,4,5] E = [49,20,28] |
A list contains numbers that are the amount of HP damage caused by a series of attacks. Your character starts with 159HP. 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 each number from 1 to 13
Use: loops[2]
|
|
|
|
A right angled triangle has 2 shorter sides of 8 and 8. Calculate the other side (the "hypotenuse").
Use: variables, sqrt()[2]
|
|
|
|
Do the sum 38 - 64 and print the result
Use: [1]
|
|
|
|
Use a loop to print the sum of the numbers from 0 to 5
Use: variables, loops[2]
|
|
|
|
Create a function that duplicates a string. It has two arguments: the string to duplicate and a number that is how many times to duplicate. It returns the duplicated string. For example the string "dog" duplicated twice returns "dogodog".
Use: variables, functions[2]
|
|
|
Test Using: String = 'sus' String = '' String = 'hi you' |
|