Code Writer
Level 3, 2026-11-14
Answers should be legal Python code, including indentation. Use the underscore _ to show a space.
Special functions: print(), range(), sqrt(), str()
Use a loop to print the average of the numbers from 9 to 19
Use: variables, loops[2]
|
|
|
|
Use a loop to print the sum of the numbers from 9 to 28
Use: variables, loops[2]
|
|
|
|
Set a variable to one value then change that value
Use: variables[1]
|
|
|
|
A right angled triangle has 2 shorter sides of 5 and 5. Calculate the other side (the "hypotenuse").
Use: variables, sqrt()[2]
|
|
|
|
Use a loop to add the numbers from 0 to 30
Use: variables, loops[2]
|
|
|
|
Use a loop to add the numbers from 9 to 34
Use: variables, loops[2]
|
|
|
|
Assume you have 2 lists of numbers with 9 elements each: Z and VAR. Add the 9th elements of the lists together.
Use: variables[1]
|
|
|
Test Using: Z = [1,2,3,...,9], VAR = [1,2,3,...,9] |
Assume you have a variable Q. If Q is bigger than 6 print "big", otherwise print "small"
Use: variables, if[2]
|
|
|
Test Using: Q = 0 Q = 5 Q = 10 |
Assume you have two non-empty lists of numbers E and B. Create a new variable that is equal to the first element of each list added together.
Use: variables[1]
|
|
|
Test Using: E = [1], B = [1] E = [1,2,3], B = [3,2,1] E = [99,94,12], B = [40,54,71] |
|