Code Writer
Level 3, 2026-11-24
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 B. Write code to count how many numbers in the list are bigger than or equal to than 4
Use: variables, loops, if[3]
|
|
|
Test Using: B = [] B = [4,0,25] B = [80,37,1] |
Use a loop to print a list of numbers, including a line number on each line
Use: variables, loops, str()[2]
|
|
|
|
Assume you have a variable Z. If Z is smaller than 9 add 5 to it, otherwise subtract 8 from it
Use: variables, if[2]
|
|
|
Test Using: Z = 0 Z = 9 Z = 10 |
A right angled triangle has a hypotenuse (longest side, opposite the right angle) of 15 and another side of 7. Calculate the length of the missing side.
Use: variables, sqrt()[2]
|
|
|
|
Assume you have a list of names, VAR. Write code to count the number of times the name "Edward" appears in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: VAR = [] VAR = ['Edward'] VAR = ['Edward','Julie','Edward','Edward'] |
Print each number from 0 to 9
Use: loops[2]
|
|
|
|
Assume you have a list variable LIST. Count the number of items in LIST and print the result.
Use: loops, variables[2]
|
|
|
Test Using: LIST = ['a','b','c'] LIST = [1,2,3,4,5,6] LIST = [] |
|