Code Writer
Level 3, 2026-06-08
Answers should be legal Python code, including indentation. Use the underscore _ to show a space.
Special functions: print(), range(), sqrt(), str()
Set two variables to different strings then make a new variable that combines them with a "a" in between
Use: variables[1]
|
|
|
|
Use a loop to add the numbers from 0 to 42
Use: variables, loops[2]
|
|
|
|
Assume you have a non-empty list of scores A for your math class. Calculate the sum of the scores.
Use: variables, loops[3]
|
|
|
Test Using: A = [10] A = [1,2,3,4,5] A = [71,13,22] |
A right angled triangle has 2 shorter sides of 3 and 5. Calculate the other side (the "hypotenuse").
Use: variables, sqrt()[2]
|
|
|
|
A list contains numbers that are the amount of HP damage caused by a series of attacks. Your character starts with 152HP. 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] |
Assume you have a non-empty list Z. Create a new variable that is equal to the first element in the list.
Use: variables[1]
|
|
|
Test Using: Z = [1] Z = ['a','b','c'] Z = [29,21,31] |
Use a loop to multiply the numbers from 1 to 16
Use: variables, loops[2]
|
|
|
|
Assume you have 2 lists of numbers with 11 elements each: B and VAR. Add the 4th elements of the lists together.
Use: variables[1]
|
|
|
Test Using: B = [1,2,3,...,11], VAR = [1,2,3,...,11] |
|