Code Writer
Level 3, 2026-03-01
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 7 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 171HP. 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 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 = 18 |
Assume you have two non-empty lists of numbers Y and Q. Create a new variable that is equal to the first element of each list added together.
Use: variables[1]
|
|
|
Test Using: Y = [1], Q = [1] Y = [1,2,3], Q = [3,2,1] Y = [27,77,36], Q = [52,16,29] |
Use a loop to multiply the numbers from 1 to 16
Use: variables, loops[2]
|
|
|
|
Create a list containing 5 animals and then print each one
Use: variables, loops[2]
|
|
|
|
Print a variable that contains your first name
Use: variables[1]
|
|
|
|
Assume you have a list variable LIST. Count the number of items in LIST.
Use: loops, variables[2]
|
|
|
Test Using: LIST = ['a','b','c'] LIST = [1,2,3,4,5,6] LIST = [] |
|