Code Writer
Level 3, 2026-10-21
Answers should be legal Python code, including indentation. Use the underscore _ to show a space.
Special functions: print(), range(), sqrt(), str()
Do the sum 40 - 45 in code and store the result
Use: variables[1]
|
|
|
|
Assume you have 2 variables S and T that are equal to the sides of a rectangle. Calculate another variable that is equal to the perimeter of the rectangle.
Use: variables[2]
|
|
|
Test Using: S = 82, T = 58 |
Use a loop to add the numbers from 2 to 26
Use: variables, loops[2]
|
|
|
|
Assume you have 2 lists of numbers that are the same size: VAR and B. Count how many times an element in VAR is bigger than or equal to the element in the same position in B.
Use: variables, loops[2]
|
|
|
Test Using: VAR = [5], B = [5] VAR = [1,2,3], B = [3,2,1] VAR = [54,88,35], B = [12,66,67] |
Assume you have a variable A. If A is bigger than 7 print "big", otherwise print "small"
Use: variables, if[2]
|
|
|
Test Using: A = 0 A = 5 A = 10 |
Assume you have a non-empty list Z. Create a new variable that is equal to the first element in the list.
Use: variables[1]
|
|
|
Test Using: Z = [1] Z = ['a','b','c'] Z = [34,48,11] |
Print each number from 0 to 38
Use: loops[2]
|
|
|
|
Assume you have a list B with at least 2 elements. Create a new variable that is equal to the first two elements added together.
Use: variables[1]
|
|
|
Test Using: B = ['a','b','c'] B = ['big','dog'] B = [48,67,29] |
Set two variables to different values then add them together
Use: variables[1]
|
|
|
|
Do the sum 23 - 43 in code and store the result
Use: variables[1]
|
|
|
|
|