Code Writer
Level 3, 2026-12-06
Answers should be legal Python code, including indentation. Use the underscore _ to show a space.
Special functions: print(), range(), sqrt(), str()
A right angled triangle has 2 shorter sides of 8 and 3. Calculate the other side (the "hypotenuse").
Use: variables, sqrt()[2]
|
|
|
|
Assume you have a list of names, F. Write code to count the number of times the name "Melissa" appears in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: F = [] F = ['Melissa'] F = ['Melissa','Julie','Felix','Melissa'] |
Use a loop to add the numbers from 0 to 20
Use: variables, loops[2]
|
|
|
|
Print your first name
Use: [1]
|
|
|
|
Use a loop to add the numbers from 5 to 23
Use: variables, loops[2]
|
|
|
|
Assume you have 2 lists of numbers that are the same size: A and X. Count how many times an element in A is equal to the element in the same position in X.
Use: variables, loops[2]
|
|
|
Test Using: A = [5], X = [5] A = [1,2,3], X = [3,2,1] A = [54,70,18], X = [81,20,81] |
A list contains numbers that are the amount of HP damage caused by a series of attacks. Your character starts with 172HP. 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] |
Set two variables to different strings then make a new variable that combines them with a "c" in between
Use: variables[1]
|
|
|
|
|