Code Writer
Level 3, 2026-08-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 list of numbers B. Write code to add up the numbers in the list that are smaller than 5
Use: variables, loops, if[3]
|
|
|
Test Using: B = [] B = [5,6,7,8,9,10,11,12,13,14,15] B = [65,78,9] |
Assume you have a list variable LIST. Count the number of items in LIST.
Use: loops, variables[2]
|
|
|
Test Using: LIST = ['a','b','c'] LIST = [1,2,3,4,5,6] LIST = [] |
Assume you have 2 variables S and T that are equal to the sides of a rectangle. Calculate another variable that is equal to the perimeter of the rectangle.
Use: variables[2]
|
|
|
Test Using: S = 75, T = 64 |
Use a loop to print the average of the numbers from 3 to 15
Use: variables, loops[2]
|
|
|
|
Do the sum 50 - 30 in code and store the result
Use: variables[1]
|
|
|
|
Use a loop to print the sum of the numbers from 9 to 20
Use: variables, loops[2]
|
|
|
|
Do the sum 40 * 62 and print the result
Use: [1]
|
|
|
|
Use a loop to add the numbers from 0 to 32
Use: variables, loops[2]
|
|
|
|
|