Code Writer
Level 3, 2026-03-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 list of numbers B. Write code to add up the numbers in the list that are smaller than or equal to than 7
Use: variables, loops, if[3]
|
|
|
Test Using: B = [] B = [5,6,7,8,9,10,11,12,13,14,15] B = [76,72,92] |
Assume you have a list of letters Y. Write code to count the number of times the letter "d" appears in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: Y = [] Y = ['d','a','z'] Y = ['d','d','d'] |
Assume you have a variable S that is the length of the side of a square. Calculate another variable that is equal to the area of the square.
Use: variables[2]
|
|
|
Test Using: S = 36 |
Assume you have 2 lists of numbers with 5 elements each: F and Z. Add the 4th elements of the lists together.
Use: variables[1]
|
|
|
Test Using: F = [1,2,3,...,5], Z = [1,2,3,...,5] |
A right angled triangle has a hypotenuse (longest side, opposite the right angle) of 15 and another side of 3. Calculate the length of the missing side.
Use: variables, sqrt()[2]
|
|
|
|
A list contains numbers that are the amount of HP damage caused by a series of attacks. Your character starts with 175HP. 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] |
Create a list containing 2 colors and then print each one
Use: variables, loops[2]
|
|
|
|
|