Code Writer
Level 3, 2026-06-21
Answers should be legal Python code, including indentation. Use the underscore _ to show a space.
Special functions: print(), range(), sqrt(), str()
A right angled triangle has a hypotenuse (longest side, opposite the right angle) of 10 and another side of 1. Calculate the length of the missing side.
Use: variables, sqrt()[2]
|
|
|
|
Assume you have two non-empty lists of numbers Y and VAR. Create a new variable that is equal to the first element of each list added together.
Use: variables[1]
|
|
|
Test Using: Y = [1], VAR = [1] Y = [1,2,3], VAR = [3,2,1] Y = [4,78,22], VAR = [84,8,43] |
Assume you have a list of numbers Z. Write code to add up the numbers in the list that are smaller than or equal to than 4
Use: variables, loops, if[3]
|
|
|
Test Using: Z = [] Z = [5,6,7,8,9,10,11,12,13,14,15] Z = [18,62,1] |
Create two strings and join them together with a space between
Use: variables[1]
|
|
|
|
Use a loop to multiply the numbers from 1 to 22
Use: variables, loops[2]
|
|
|
|
Assume you have a list variable LIST. Count the number of items in LIST and print the result.
Use: loops, variables[2]
|
|
|
Test Using: LIST = ['a','b','c'] LIST = [1,2,3,4,5,6] LIST = [] |
A triangle has sides of 3, 8 and 8. Create variables for the sides of the triangle and then calculate its perimeter.
Use: variables[2]
|
|
|
|
Use a loop to create a string that has 32 "G" characters
Use: variables, loops[2]
|
|
|
|
|