Code Writer
Level 3, 2026-09-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 6, 3 and 5. Create variables for the sides of the triangle and then calculate its perimeter.
Use: variables[2]
|
|
|
|
Use a loop to add the numbers from 0 to 21
Use: variables, loops[2]
|
|
|
|
Assume you have a variable Z. If Z is bigger than 9 print "big", otherwise print "small"
Use: variables, if[2]
|
|
|
Test Using: Z = 0 Z = 5 Z = 10 |
A right angled triangle has 2 shorter sides of 4 and 8. Calculate the other side (the "hypotenuse").
Use: variables, sqrt()[2]
|
|
|
|
Set two variables to different values then add them together
Use: variables[1]
|
|
|
|
Use a loop to print 31 lines with the numbers from 1 to 31 and each number times 19, separated by a commma.
For example, line 1 would be "1, 19", line 2 would be "2, 38",etc.
Use: variables, loops, str()[2]
|
|
|
|
Write a loop that prints "dumbdumb" 30 times
Use: loops[2]
|
|
|
|
Assume you have a list Q with at least 2 elements. Create a new variable that is equal to the first two elements added together.
Use: variables[1]
|
|
|
Test Using: Q = ['a','b','c'] Q = ['big','dog'] Q = [46,45,43] |
Assume you have a list of numbers X. Print the 8th element of X.
Use: variables[1]
|
|
|
Test Using: X = [1,2,3,4,5,6,7,8,9,10] |
|