Code Writer
Level 3, 2026-06-07
Answers should be legal Python code, including indentation. Use the underscore _ to show a space.
Special functions: print(), range(), sqrt(), str()
A triangle has sides of 8, 3 and 8. Create variables for the sides of the triangle and then calculate its perimeter.
Use: variables[2]
|
|
|
|
A right angled triangle has 2 shorter sides of 9 and 6. Calculate the other side (the "hypotenuse").
Use: variables, sqrt()[2]
|
|
|
|
A factorial of a number is all the numbers from 1 to that number multiplied together, so 4! = 1x2x3x4. Write code using a loop to calculate 66!
Use: variables, loops, str()[2]
|
|
|
|
Assume you have a list of numbers VAR. Write code to count the number of times the number 13 appears in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: VAR = [13] VAR = [0,13,-1,13,99,13] VAR = [22,90,27] |
Set two variables to different strings then make a new variable that combines them with a "E" in between
Use: variables[1]
|
|
|
|
Use a loop to multiply the numbers from 1 to 42
Use: variables, loops[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 = 46 |
Assume you have a list of letters Q. Write code to count the number of times the letter "E" appears in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: Q = [] Q = ['E','a','z'] Q = ['E','E','E'] |
|