Code Writer
Level 3, 2026-05-17
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 2 shorter sides of 2 and 4. Calculate the other side (the "hypotenuse").
Use: variables, sqrt()[2]
|
|
|
|
Use a loop to print 22 lines with a line number and the word "error". For example, line 1 should be "1: error", line 2 would be "2: error", etc.
Use: variables, loops, str()[2]
|
|
|
|
A right angled triangle has 2 shorter sides of 2 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 37!
Use: variables, loops, str()[2]
|
|
|
|
Print a variable that contains your first name
Use: variables[1]
|
|
|
|
Create a list containing 2 numbers
Use: variables[1]
|
|
|
|
Use a loop to multiply the numbers from 1 to 23
Use: variables, loops[2]
|
|
|
|
Assume you have a non-empty list of numbers VAR. Create a new variable that is equal all the numbers in VAR multiplied together.
Use: variables, loops[2]
|
|
|
Test Using: VAR = [1,1] VAR = [1,2,3,4,5] VAR = [85,28,61] |
Assume you have 2 lists of numbers with 10 elements each: B and E. Add the 10th elements of the lists together.
Use: variables[1]
|
|
|
Test Using: B = [1,2,3,...,10], E = [1,2,3,...,10] |
|