Code Writer
Level 3, 2026-05-26
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 of numbers. Use a variable to add the items in the list
Use: variables, loops[2]
|
|
|
Test Using: LIST = [1] LIST = [1,2,3,4,5,6,7,8,9] LIST = [33,2,33] |
Use a loop to print the average of the numbers from 0 to 1
Use: variables, loops[2]
|
|
|
|
Print a variable that contains your first name
Use: variables[1]
|
|
|
|
Do the sum 23 - 93 in code and store the result
Use: variables[1]
|
|
|
|
Assume you have a non-empty list Y. Print the first element in the list.
Use: variables[1]
|
|
|
Test Using: Y = [1] Y = ['b','a','c'] Y = [69,31,63] |
Use a loop to print 23 lines with the numbers from 1 to 23 and each number times 12, separated by a commma.
For example, line 1 would be "1, 12", line 2 would be "2, 24",etc.
Use: variables, loops, str()[2]
|
|
|
|
A triangle has sides of 8, 3 and 6. Create variables for the sides of the triangle and then calculate its perimeter.
Use: variables[2]
|
|
|
|
Assume you have a non-empty list Q. Create a new variable that is equal to the first element in the list.
Use: variables[1]
|
|
|
Test Using: Q = [1] Q = ['a','b','c'] Q = [25,45,12] |
Print a list of strings, including a line number on each line
Use: variables, loops, str()[2]
|
|
|
|
Assume you have a list of numbers Z. Print the 4th element of Z.
Use: variables[1]
|
|
|
Test Using: Z = [1,2,3,4,5,6,7,8,9,10] |
|