Code Writer
Level 3, 2026-06-18
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 Y. If Y is smaller than 2 add 9 to it, otherwise subtract 4 from it
Use: variables, if[2]
|
|
|
Test Using: Y = 0 Y = 2 Y = 10 |
Write a loop that prints "diddles" 57 times
Use: loops[2]
|
|
|
|
Print each number from 2 to 13
Use: loops[2]
|
|
|
|
Assume you have a non-empty list of scores Z for your math class. Calculate the average of the scores.
Use: variables, loops[3]
|
|
|
Test Using: Z = [10] Z = [1,2,3,4,5] Z = [46,83,13] |
Assume you have a variable VAR. If VAR is bigger than 6 print "big", otherwise print "small"
Use: variables, if[2]
|
|
|
Test Using: VAR = 0 VAR = 5 VAR = 10 |
Use a loop to multiply the numbers from 1 to 40
Use: variables, loops[2]
|
|
|
|
Assume you have a list of names, X. Write code to count the number of times the name "Mike" appears in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: X = [] X = ['Mike'] X = ['Mike','Max','Felix','Mike'] |
|