Code Writer
Level 3, 2026-05-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 variable Z. If Z is smaller than 5 add 9 to it, otherwise subtract 5 from it
Use: variables, if[2]
|
|
|
Test Using: Z = 0 Z = 5 Z = 10 |
Assume you have a list of numbers Q. Write code to count how many numbers in the list are smaller than or equal to than 10
Use: variables, loops, if[3]
|
|
|
Test Using: Q = [] Q = [10,0,25] Q = [6,82,84] |
Set two variables to different values then add them together
Use: variables[1]
|
|
|
|
Assume you have a list of names, Y. Write code to count the number of times the name "Max" appears in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: Y = [] Y = ['Max'] Y = ['Max','Edward','Octavian','Max'] |
Assume you have a non-empty list Q. Print the first element in the list.
Use: variables[1]
|
|
|
Test Using: Q = [1] Q = ['b','a','c'] Q = [22,70,72] |
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 = [] |
Use a loop to print the sum of the numbers from 3 to 17
Use: variables, loops[2]
|
|
|
|
Use a loop to print the average of the numbers from 0 to 3
Use: variables, loops[2]
|
|
|
|
|