Code Writer
Level 3, 2026-06-10
Answers should be legal Python code, including indentation. Use the underscore _ to show a space.
Special functions: print(), range(), sqrt(), str()
Assume you have a non-empty list of numbers E. Write code to find the smallest number in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: E = [1,2,3] E = [3,2,1,0] E = [13,77,53] |
Assume you have a list of numbers X. Write code to count how many numbers in the list are smaller than or equal to than 17
Use: variables, loops, if[3]
|
|
|
Test Using: X = [] X = [17,0,25] X = [1,76,52] |
Assume you have a list of numbers E. Create a new variable that is equal to sum of all the numbers in E.
Use: variables, loops[2]
|
|
|
Test Using: E = [] E = [1,1] E = [97,85,66] |
Set two variables to different values then add them together
Use: variables[1]
|
|
|
|
A list contains numbers that are the amount of HP damage caused by a series of attacks. Your character starts with 164HP. 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 list of letters Z. Write code to count the number of times the letter "G" appears in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: Z = [] Z = ['G','a','z'] Z = ['G','G','G'] |
Use a loop to print a list of numbers, including a line number on each line
Use: variables, loops, str()[2]
|
|
|
|
|