Code Writer
Level 3, 2026-07-06
Answers should be legal Python code, including indentation. Use the underscore _ to show a space.
Special functions: print(), range(), sqrt(), str()
Assume you have two non-empty lists of numbers B and E. Create a new variable that is equal to the first element of each list added together.
Use: variables[1]
|
|
|
Test Using: B = [1], E = [1] B = [1,2,3], E = [3,2,1] B = [4,39,47], E = [52,100,31] |
Assume you have a list of numbers A. Write code to add up the numbers in the list that are smaller than 14
Use: variables, loops, if[3]
|
|
|
Test Using: A = [] A = [5,6,7,8,9,10,11,12,13,14,15] A = [60,8,48] |
Do the sum 65 / 63 in code and store the result
Use: variables[1]
|
|
|
|
Assume you have a list of names, Y. Write code to count the number of times the name "Mongo" appears in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: Y = [] Y = ['Mongo'] Y = ['Mongo','Mongo','Felix','Mongo'] |
A list contains numbers that are the amount of HP damage caused by a series of attacks. Your character starts with 146HP. 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 A with at least 2 elements. Create a new variable that is equal to the first two elements added together.
Use: variables[1]
|
|
|
Test Using: A = ['a','b','c'] A = ['big','dog'] A = [59,24,35] |
Create a list containing 2 fruit
Use: variables[1]
|
|
|
|
Use a loop to multiply the numbers from 1 to 34
Use: variables, loops[2]
|
|
|
|
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 = [4,39,47], Z = [52,100,31] |
|