Code Writer
Level 3, 2026-08-07
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 of numbers Y. Create a new variable that is equal to sum of all the numbers in Y.
Use: variables, loops[2]
|
|
|
Test Using: Y = [] Y = [1,1] Y = [45,54,58] |
Print each number from 9 to 25
Use: loops[2]
|
|
|
|
Assume you have 2 lists of numbers that are the same size: Q and X. Count how many times an element in Q is bigger than or equal to the element in the same position in X.
Use: variables, loops[2]
|
|
|
Test Using: Q = [5], X = [5] Q = [1,2,3], X = [3,2,1] Q = [84,47,9], X = [74,70,16] |
Print your first name
Use: [1]
|
|
|
|
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 1HP 2 is a medium attack taking 6HP 3 is a strong attack taking 12HP
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 = [41,16,16] |
Use a loop to add the numbers from 5 to 21
Use: variables, loops[2]
|
|
|
|
Print each number from 0 to 34
Use: loops[2]
|
|
|
|
Assume you have two non-empty lists of numbers F and Q. Create a new variable that is equal to the first element of each list added together.
Use: variables[1]
|
|
|
Test Using: F = [1], Q = [1] F = [1,2,3], Q = [3,2,1] F = [1,44,90], Q = [53,9,5] |
|