Code Writer
Level 3, 2026-10-23
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 list variable LIST. Print each value in LIST.
Use: loops[2]
|
|
|
Test Using: LIST = [1,2,3] LIST = ['a','b',0] LIST = [] |
Do the sum 49 * 99 in code and store the result
Use: variables[1]
|
|
|
|
A list contains numbers that are the amount of HP damage caused by a series of attacks. Your character starts with 101HP. 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] |
Print each number from 0 to 18
Use: loops[2]
|
|
|
|
Assume you have a list of names, F. Write code to count the number of times the name "Jenny" appears in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: F = [] F = ['Jenny'] F = ['Jenny','Missy','Julie','Jenny'] |
Assume you have a list of numbers F. Write code to add up the numbers in the list that are smaller than 5
Use: variables, loops, if[3]
|
|
|
Test Using: F = [] F = [5,6,7,8,9,10,11,12,13,14,15] F = [37,95,57] |
Assume you have two non-empty lists of numbers F and Z. Create a new variable that is equal to the first element of each list added together.
Use: variables[1]
|
|
|
Test Using: F = [1], Z = [1] F = [1,2,3], Z = [3,2,1] F = [24,23,94], Z = [14,43,22] |
Assume you have a non-empty list Y. Print the first element in the list.
Use: variables[1]
|
|
|
Test Using: Y = [1] Y = ['b','a','c'] Y = [45,69,64] |
|