Code Writer
Level 3, 2026-02-17
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 A. Write code to count how many numbers in the list are smaller than 12
Use: variables, loops, if[3]
|
|
|
Test Using: A = [] A = [12,0,25] A = [18,99,70] |
Print each number from 1 to 34
Use: loops[2]
|
|
|
|
Use a loop to print 79 lines with the numbers from 1 to 79 and each number times 7, separated by a commma.
For example, line 1 would be "1, 7", line 2 would be "2, 14",etc.
Use: variables, loops, str()[2]
|
|
|
|
Print a list of strings, including a line number on each line
Use: variables, loops, str()[2]
|
|
|
|
Assume you have a non-empty list of numbers A. Write code to find the smallest number in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: A = [1,2,3] A = [3,2,1,0] A = [19,10,49] |
Assume you have a list X with at least 2 elements. Create a new variable that is equal to the first two elements added together.
Use: variables[1]
|
|
|
Test Using: X = ['a','b','c'] X = ['big','dog'] X = [77,38,14] |
Assume you have 2 lists of numbers that are the same size: F and E. Count how many times an element in F is bigger than or equal to the element in the same position in E.
Use: variables, loops[2]
|
|
|
Test Using: F = [5], E = [5] F = [1,2,3], E = [3,2,1] F = [54,24,78], E = [79,95,47] |
Do the sum 80 / 40 in code and store the result
Use: variables[1]
|
|
|
|
|