Code Writer
Level 3, 2026-10-16
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 F. Print the 9th element of F.
Use: variables[1]
|
|
|
Test Using: F = [1,2,3,4,5,6,7,8,9,10] |
Assume you have a list of letters X. Write code to count the number of times the letter "c" appears in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: X = [] X = ['c','a','z'] X = ['c','c','c'] |
Use a loop to print the average of the numbers from 7 to 21
Use: variables, loops[2]
|
|
|
|
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 = [] |
Use a loop to print a list of numbers, including a line number on each line
Use: variables, loops, str()[2]
|
|
|
|
Create a list containing 3 fruit and then print each one
Use: variables, loops[2]
|
|
|
|
A triangle has sides of 2, 6 and 2. Create variables for the sides of the triangle and then calculate its perimeter.
Use: variables[2]
|
|
|
|
Use a loop to print the average of the numbers from 0 to 1
Use: variables, loops[2]
|
|
|
|
|