Code Writer
Level 3, 2026-07-10
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 of numbers Q. Write code to count the number of times the number 28 appears in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: Q = [28] Q = [0,28,-1,28,99,28] Q = [32,47,13] |
A right angled triangle has 2 shorter sides of 7 and 1. Calculate the other side (the "hypotenuse").
Use: variables, sqrt()[2]
|
|
|
|
Assume you have a list variable LIST. Print each value in LIST.
Use: loops[2]
|
|
|
Test Using: LIST = [1,2,3] LIST = ['a','b',0] LIST = [] |
Assume you have a variable B. If B is smaller than 3 add 9 to it, otherwise subtract 2 from it
Use: variables, if[2]
|
|
|
Test Using: B = 0 B = 3 B = 10 |
Assume you have a variable Z. If Z is bigger than 4 print "big", otherwise print "small"
Use: variables, if[2]
|
|
|
Test Using: Z = 0 Z = 5 Z = 10 |
Print each number from 1 to 44
Use: loops[2]
|
|
|
|
Print each number from 5 to 14
Use: loops[2]
|
|
|
|
Set two variables to different strings then make a new variable that combines them with a "B" in between
Use: variables[1]
|
|
|
|
|