Code Writer
Level 3, 2026-02-27
Answers should be legal Python code, including indentation. Use the underscore _ to show a space.
Special functions: print(), range(), sqrt(), str()
Use a loop to print 71 lines with a line number and the word "fake". For example, line 1 should be "1: fake", line 2 would be "2: fake", etc.
Use: variables, loops, str()[2]
|
|
|
|
A right angled triangle has a hypotenuse (longest side, opposite the right angle) of 11 and another side of 3. Calculate the length of the missing side.
Use: variables, sqrt()[2]
|
|
|
|
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 3HP 2 is a medium attack taking 6HP 3 is a strong attack taking 19HP
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 = [65,43,31] |
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 = [94,31,36] |
Set a variable to one value then change that value
Use: variables[1]
|
|
|
|
Use a loop to create a string that has 27 "g" characters
Use: variables, loops[2]
|
|
|
|
Print each number from 1 to 42
Use: loops[2]
|
|
|
|
Do the sum 39 - 53 in code and store the result
Use: variables[1]
|
|
|
|
|