Code Writer
Level 3, 2026-08-06
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 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 = [92,20,79] |
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 right angled triangle has a hypotenuse (longest side, opposite the right angle) of 14 and another side of 5. Calculate the length of the missing side.
Use: variables, sqrt()[2]
|
|
|
|
Assume you have a variable S that is the length of the side of a square. Calculate another variable that is equal to the area of the square.
Use: variables[2]
|
|
|
Test Using: S = 59 |
A triangle has sides of 8, 6 and 8. Create variables for the sides of the triangle and then calculate its perimeter.
Use: variables[2]
|
|
|
|
Use a loop to print the average of the numbers from 8 to 24
Use: variables, loops[2]
|
|
|
|
Use a loop to add the numbers from 0 to 32
Use: variables, loops[2]
|
|
|
|
Set two variables to different strings then make a new variable that combines them with a "c" in between
Use: variables[1]
|
|
|
|
Create two strings and join them together with a space between
Use: variables[1]
|
|
|
|
|