Code Writer
Level 3, 2026-11-25
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 multiply the numbers from 9 to 19
Use: variables, loops[2]
|
|
|
|
Use a loop to add the numbers from 0 to 30
Use: variables, loops[2]
|
|
|
|
Assume you have a list of numbers Z. 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: Z = [] Z = [5,6,7,8,9,10,11,12,13,14,15] Z = [100,66,91] |
Use a loop to print the average of the numbers from 6 to 20
Use: variables, loops[2]
|
|
|
|
Set a variable to one value then change that value
Use: variables[1]
|
|
|
|
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 37!
Use: variables, loops, str()[2]
|
|
|
|
Assume you have a non-empty list F. Create a new variable that is equal to the first element in the list.
Use: variables[1]
|
|
|
Test Using: F = [1] F = ['a','b','c'] F = [83,35,33] |
Assume you have a non-empty list of numbers X. Create a new variable that is equal all the numbers in X multiplied together.
Use: variables, loops[2]
|
|
|
Test Using: X = [1,1] X = [1,2,3,4,5] X = [21,75,45] |
|