Code Writer
Level 3, 2026-11-01
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 8 add 5 to it, otherwise subtract 5 from it
Use: variables, if[2]
|
|
|
Test Using: Z = 0 Z = 8 Z = 10 |
Use a loop to print 73 lines with a line number and the word "bloop". For example, line 1 should be "1: bloop", line 2 would be "2: bloop", etc.
Use: variables, loops, str()[2]
|
|
|
|
Assume you have a list of letters A. Write code to count the number of times the letter "C" appears in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: A = [] A = ['C','a','z'] A = ['C','C','C'] |
Assume you have a variable VAR. If VAR is bigger than 5 print "big", otherwise print "small"
Use: variables, if[2]
|
|
|
Test Using: VAR = 0 VAR = 5 VAR = 10 |
Use a loop to add the numbers from 7 to 19
Use: variables, loops[2]
|
|
|
|
Assume you have a list of numbers Q. Write code to add up the numbers in the list that are smaller than or equal to than 10
Use: variables, loops, if[3]
|
|
|
Test Using: Q = [] Q = [5,6,7,8,9,10,11,12,13,14,15] Q = [93,38,42] |
Create a list containing 3 numbers and then print each one
Use: variables, loops[2]
|
|
|
|
|