Code Writer
Level 3, 2026-11-09
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 non-empty list of numbers Y. Create a new variable that is equal all the numbers in Y multiplied together.
Use: variables, loops[2]
|
|
|
Test Using: Y = [1,1] Y = [1,2,3,4,5] Y = [92,48,100] |
Assume you have two non-empty lists of numbers Y and B. Create a new variable that is equal to the first element of each list added together.
Use: variables[1]
|
|
|
Test Using: Y = [1], B = [1] Y = [1,2,3], B = [3,2,1] Y = [9,32,21], B = [45,48,24] |
Assume you have a list of numbers Q. Write code to add up the numbers in the list that are smaller than 13
Use: variables, loops, if[3]
|
|
|
Test Using: Q = [] Q = [5,6,7,8,9,10,11,12,13,14,15] Q = [86,93,62] |
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 = [] |
Assume you have a list of numbers VAR. Write code to add up the numbers in the list that are bigger than 12
Use: variables, loops, if[3]
|
|
|
Test Using: VAR = [] VAR = [5,6,7,8,9,10,11,12,13,14,15] VAR = [86,93,62] |
Assume you have a list of numbers F. Write code to count the number of times the number 39 appears in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: F = [39] F = [0,39,-1,39,99,39] F = [75,56,98] |
A triangle has sides of 4, 3 and 2. Create variables for the sides of the triangle and then calculate its perimeter.
Use: variables[2]
|
|
|
|
|