Code Writer
Level 3, 2026-11-30
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 non-empty list of numbers Y. Write code to find the smallest number in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: Y = [1,2,3] Y = [3,2,1,0] Y = [17,18,27] |
Print a variable that contains your first name
Use: variables[1]
|
|
|
|
Set two variables to different strings then make a new variable that combines them with a "a" in between
Use: variables[1]
|
|
|
|
Use a loop to add the numbers from 0 to 36
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 30!
Use: variables, loops, str()[2]
|
|
|
|
Assume you have a variable S that is the length of the side of a square. Calculate another variable that is equal to the perimeter of the square.
Use: variables[2]
|
|
|
Test Using: S = 76 |
Assume you have 2 lists of numbers with 15 elements each: Z and X. Add the 8th elements of the lists together.
Use: variables[1]
|
|
|
Test Using: Z = [1,2,3,...,15], X = [1,2,3,...,15] |
Set a variable to one value then change that value
Use: variables[1]
|
|
|
|
Use a loop to print the sum of the numbers from 0 to 7
Use: variables, loops[2]
|
|
|
|
Assume you have a list of numbers Y. Print the 8th element of Y.
Use: variables[1]
|
|
|
Test Using: Y = [1,2,3,4,5,6,7,8,9,10] |
|