Code Writer
Level 3, 2026-02-20
Answers should be legal Python code, including indentation. Use the underscore _ to show a space.
Special functions: print(), range(), sqrt(), str()
A rectangle has sides of 3 and 6. Create variables for the sides of the shape and then calculate its area
Use: variables[2]
|
|
|
|
A list contains numbers that are the amount of HP damage caused by a series of attacks. Your character starts with 137HP. 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] |
Use a loop to print a list of numbers, including a line number on each line
Use: variables, loops, str()[2]
|
|
|
|
Use a loop to print 86 lines with the numbers from 1 to 86 and each number times 20, separated by a commma.
For example, line 1 would be "1, 20", line 2 would be "2, 40",etc.
Use: variables, loops, str()[2]
|
|
|
|
Print each number from 1 to 19
Use: loops[2]
|
|
|
|
Print a list of strings, including a line number on each line
Use: variables, loops, str()[2]
|
|
|
|
Assume you have two non-empty lists of numbers A and VAR. Create a new variable that is equal to the first element of each list added together.
Use: variables[1]
|
|
|
Test Using: A = [1], VAR = [1] A = [1,2,3], VAR = [3,2,1] A = [43,67,77], VAR = [7,33,18] |
Assume you have two non-empty lists of numbers A and X. Create a new variable that is equal to the first element of each list added together.
Use: variables[1]
|
|
|
Test Using: A = [1], X = [1] A = [1,2,3], X = [3,2,1] A = [43,67,77], X = [7,33,18] |
|