Code Writer
Level 3, 2026-02-17
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 variable Q. If Q is bigger than 3 print "big", otherwise print "small"
Use: variables, if[2]
|
|
|
Test Using: Q = 0 Q = 5 Q = 10 |
Use a loop to print the average of the numbers from 0 to 4
Use: variables, loops[2]
|
|
|
|
A factorial of a number is all the numbers from 1 to that number multiplied together, so 4! = 1x2x3x4. Write code using a loop to calculate 31!
Use: variables, loops, str()[2]
|
|
|
|
Use a loop to print the average of the numbers from 9 to 29
Use: variables, loops[2]
|
|
|
|
Use a loop to add the numbers from 3 to 31
Use: variables, loops[2]
|
|
|
|
Assume you have a variable Y. If Y is smaller than 8 add 6 to it, otherwise subtract 9 from it
Use: variables, if[2]
|
|
|
Test Using: Y = 0 Y = 8 Y = 10 |
Set two variables to different strings then make a new variable that combines them with a "c" in between
Use: variables[1]
|
|
|
|
Assume you have a list of numbers X. Create a new variable that is equal to sum of all the numbers in X.
Use: variables, loops[2]
|
|
|
Test Using: X = [] X = [1,1] X = [88,17,57] |
|