Code Writer
Level 3, 2026-10-24
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 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 = 93, T = 24 |
Assume you have a list of numbers X. Create a new variable that is equal to sum of all the numbers in X.
Use: variables, loops[2]
|
|
|
Test Using: X = [] X = [1,1] X = [25,53,53] |
Print a variable that contains your first name
Use: variables[1]
|
|
|
|
A right angled triangle has a hypotenuse (longest side, opposite the right angle) of 9 and another side of 7. Calculate the length of the missing side.
Use: variables, sqrt()[2]
|
|
|
|
Assume you have a non-empty list Y. Create a new variable that is equal to the first element in the list.
Use: variables[1]
|
|
|
Test Using: Y = [1] Y = ['a','b','c'] Y = [44,77,9] |
Use a loop to print a list of numbers, including a line number on each line
Use: variables, loops, str()[2]
|
|
|
|
Print your first name
Use: [1]
|
|
|
|
Assume you have a list of numbers B. Write code to add up the numbers in the list that are bigger than 16
Use: variables, loops, if[3]
|
|
|
Test Using: B = [] B = [5,6,7,8,9,10,11,12,13,14,15] B = [91,94,48] |
Assume you have two non-empty lists of numbers Q and VAR. Create a new variable that is equal to the first element of each list added together.
Use: variables[1]
|
|
|
Test Using: Q = [1], VAR = [1] Q = [1,2,3], VAR = [3,2,1] Q = [77,8,68], VAR = [18,17,16] |
|