Code Writer
Level 3, 2026-09-30
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 variable LIST. Count the number of items in LIST and print the result.
Use: loops, variables[2]
|
|
|
Test Using: LIST = ['a','b','c'] LIST = [1,2,3,4,5,6] LIST = [] |
Assume you have a list of letters Q. Write code to count the number of times the letter "C" appears in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: Q = [] Q = ['C','a','z'] Q = ['C','C','C'] |
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 = 80, T = 66 |
Assume you have a non-empty list of numbers F. Create a new variable that is equal all the numbers in F multiplied together.
Use: variables, loops[2]
|
|
|
Test Using: F = [1,1] F = [1,2,3,4,5] F = [56,32,54] |
Assume you have a list of numbers Y. Write code to count how many numbers in the list are bigger than or equal to than 20
Use: variables, loops, if[3]
|
|
|
Test Using: Y = [] Y = [20,0,25] Y = [10,46,75] |
Use a loop to add the numbers from 4 to 25
Use: variables, loops[2]
|
|
|
|
Assume you have a variable S that is the length of the side of a square. Calculate another variable that is equal to the area of the square.
Use: variables[2]
|
|
|
Test Using: S = 38 |
|