Code Writer
Level 3, 2026-07-20
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 bigger than 4 print "big", otherwise print "small"
Use: variables, if[2]
|
|
|
Test Using: Z = 0 Z = 5 Z = 10 |
Use a loop to print 54 lines with a line number and the word "dumb". For example, line 1 should be "1: dumb", line 2 would be "2: dumb", etc.
Use: variables, loops, str()[2]
|
|
|
|
Set two variables to different values then add them together
Use: variables[1]
|
|
|
|
Assume you have a non-empty list VAR. Print the first element in the list.
Use: variables[1]
|
|
|
Test Using: VAR = [1] VAR = ['b','a','c'] VAR = [3,7,98] |
Write a loop that prints "diddles" 48 times
Use: loops[2]
|
|
|
|
Use a loop to print the average of the numbers from 0 to 6
Use: variables, loops[2]
|
|
|
|
Assume you have a non-empty list Z. Print the first element in the list.
Use: variables[1]
|
|
|
Test Using: Z = [1] Z = ['b','a','c'] Z = [3,7,98] |
Create two strings and join them together with a space between
Use: variables[1]
|
|
|
|
Assume you have a list of numbers VAR. Write code to add up the numbers in the list that are bigger than 8
Use: variables, loops, if[3]
|
|
|
Test Using: VAR = [] VAR = [5,6,7,8,9,10,11,12,13,14,15] VAR = [37,72,68] |
|