Code Writer
Level 3, 2026-02-22
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 list of numbers Z. Print the 5th element of Z.
Use: variables[1]
|
|
|
Test Using: Z = [1,2,3,4,5,6,7,8,9,10] |
Use a loop to add the numbers from 4 to 14
Use: variables, loops[2]
|
|
|
|
Use a loop to add the numbers from 0 to 13
Use: variables, loops[2]
|
|
|
|
Assume you have two non-empty lists of numbers Z and A. Create a new variable that is equal to the first element of each list added together.
Use: variables[1]
|
|
|
Test Using: Z = [1], A = [1] Z = [1,2,3], A = [3,2,1] Z = [89,23,62], A = [28,30,74] |
A rectangle has sides of 5 and 4. Create variables for the sides of the shape and then calculate its perimeter
Use: variables[2]
|
|
|
|
Use a loop to print the average of the numbers from 0 to 1
Use: variables, loops[2]
|
|
|
|
Use a loop to print 59 lines with the numbers from 1 to 59 and each number times 10, separated by a commma.
For example, line 1 would be "1, 10", line 2 would be "2, 20",etc.
Use: variables, loops, str()[2]
|
|
|
|
Assume you have a variable Q. If Q is bigger than 4 print "big", otherwise print "small"
Use: variables, if[2]
|
|
|
Test Using: Q = 0 Q = 5 Q = 10 |
Print your first name
Use: [1]
|
|
|
|
|