Code Writer
Level 3, 2026-07-07
Answers should be legal Python code, including indentation. Use the underscore _ to show a space.
Special functions: print(), range(), sqrt(), str()
Assume you have 2 lists of numbers with 19 elements each: B and Q. Add the 10th elements of the lists together.
Use: variables[1]
|
|
|
Test Using: B = [1,2,3,...,19], Q = [1,2,3,...,19] |
A right angled triangle has a hypotenuse (longest side, opposite the right angle) of 10 and another side of 7. Calculate the length of the missing side.
Use: variables, sqrt()[2]
|
|
|
|
Assume you have a list of letters F. Write code to count the number of times the letter "C" appears in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: F = [] F = ['C','a','z'] F = ['C','C','C'] |
Use a loop to print the sum of the numbers from 9 to 22
Use: variables, loops[2]
|
|
|
|
Print each number from 4 to 19
Use: loops[2]
|
|
|
|
Create two strings and join them together with a space between
Use: variables[1]
|
|
|
|
Assume you have a list of numbers X. Write code to count the number of times the number 47 appears in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: X = [47] X = [0,47,-1,47,99,47] X = [62,58,68] |
Assume you have 2 lists of numbers with 10 elements each: B and Z. Add the 7th elements of the lists together.
Use: variables[1]
|
|
|
Test Using: B = [1,2,3,...,10], Z = [1,2,3,...,10] |
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 area of the rectangle.
Use: variables[2]
|
|
|
Test Using: S = 88, T = 89 |
|