Code Writer
Level 3, 2026-11-03
Answers should be legal Python code, including indentation. Use the underscore _ to show a space.
Special functions: print(), range(), sqrt(), str()
Do the sum 29 - 88 and print the result
Use: [1]
|
|
|
|
Assume you have a non-empty list of numbers A. Write code to find the smallest number in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: A = [1,2,3] A = [3,2,1,0] A = [10,81,41] |
Assume you have a variable A. If A is bigger than 2 print "big", otherwise print "small"
Use: variables, if[2]
|
|
|
Test Using: A = 0 A = 5 A = 10 |
Set two variables to different strings then make a new variable that combines them with a "D" in between
Use: variables[1]
|
|
|
|
A rectangle has sides of 4 and 7. Create variables for the sides of the shape and then calculate its area
Use: variables[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 4HP 3 is a strong attack taking 16HP
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 = [66,100,92] |
Assume you have 2 lists of numbers that are the same size: E and Y. Count how many times an element in E is smaller than or equal to the element in the same position in Y.
Use: variables, loops[2]
|
|
|
Test Using: E = [5], Y = [5] E = [1,2,3], Y = [3,2,1] E = [20,53,75], Y = [34,51,77] |
Create a list containing 2 numbers
Use: variables[1]
|
|
|
|
Set two variables to different strings then make a new variable that combines them with a "a" in between
Use: variables[1]
|
|
|
|
|