Code Writer
Level 3, 2026-09-13
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 variable Q. If Q is bigger than 5 print "big", otherwise print "small"
Use: variables, if[2]
|
|
|
Test Using: Q = 0 Q = 5 Q = 10 |
Use a loop to print 40 lines with a line number and the word "moo". For example, line 1 should be "1: moo", line 2 would be "2: moo", etc.
Use: variables, loops, str()[2]
|
|
|
|
Print each number from 0 to 18
Use: loops[2]
|
|
|
|
Assume you have a list of numbers A. Write code to count the number of times the number 28 appears in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: A = [28] A = [0,28,-1,28,99,28] A = [31,86,27] |
A right angled triangle has a hypotenuse (longest side, opposite the right angle) of 11 and another side of 1. Calculate the length of the missing side.
Use: variables, sqrt()[2]
|
|
|
|
Use a loop to print 61 lines with the numbers from 1 to 61 and each number times 2, separated by a commma.
For example, line 1 would be "1, 2", line 2 would be "2, 4",etc.
Use: variables, loops, str()[2]
|
|
|
|
Assume you have 2 variables S and T that are equal to the sides of a rectangle. Calculate another variable that is equal to the perimeter of the rectangle.
Use: variables[2]
|
|
|
Test Using: S = 76, T = 18 |
Do the sum 28 / 70 and print the result
Use: [1]
|
|
|
|
|