Code Writer
Level 3, 2026-05-20
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 1 to 32
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 61!
Use: variables, loops, str()[2]
|
|
|
|
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'] |
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 42!
Use: variables, loops, str()[2]
|
|
|
|
Use a loop to print the average of the numbers from 4 to 22
Use: variables, loops[2]
|
|
|
|
Use a loop to print the average of the numbers from 7 to 20
Use: variables, loops[2]
|
|
|
|
Print a variable that contains your first name
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 = [41,15,45] |
|