Code Writer
Level 3, 2026-04-01
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 Q. Print the 10th element of Q.
Use: variables[1]
|
|
|
Test Using: Q = [1,2,3,4,5,6,7,8,9,10] |
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 = 17 |
Assume you have a list of letters A. Write code to count the number of times the letter "C" appears in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: A = [] A = ['C','a','z'] A = ['C','C','C'] |
Use a loop to multiply the numbers from 1 to 21
Use: variables, loops[2]
|
|
|
|
Assume you have a list of numbers VAR. Write code to add up the numbers in the list that are bigger than 12
Use: variables, loops, if[3]
|
|
|
Test Using: VAR = [] VAR = [5,6,7,8,9,10,11,12,13,14,15] VAR = [95,51,64] |
Assume you have a list of numbers B. Create a new variable that is equal to sum of all the numbers in B.
Use: variables, loops[2]
|
|
|
Test Using: B = [] B = [1,1] B = [84,22,80] |
A right angled triangle has 2 shorter sides of 6 and 7. Calculate the other side (the "hypotenuse").
Use: variables, sqrt()[2]
|
|
|
|
Assume you have 2 lists of numbers with 19 elements each: Y and B. Add the 10th elements of the lists together.
Use: variables[1]
|
|
|
Test Using: Y = [1,2,3,...,19], B = [1,2,3,...,19] |
|