Code Writer
Level 3, 2026-11-06
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 B with at least 2 elements. Create a new variable that is equal to the first two elements added together.
Use: variables[1]
|
|
|
Test Using: B = ['a','b','c'] B = ['big','dog'] B = [74,30,8] |
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 area of the rectangle.
Use: variables[2]
|
|
|
Test Using: S = 58, T = 88 |
Assume you have a list of numbers F. Print the 5th 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 numbers X. Write code to count how many numbers in the list are bigger than or equal to than 15
Use: variables, loops, if[3]
|
|
|
Test Using: X = [] X = [15,0,25] X = [67,2,72] |
A triangle has sides of 3, 5 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 3 to 19
Use: variables, loops[2]
|
|
|
|
Use a loop to print a list of numbers, including a line number on each line
Use: variables, loops, str()[2]
|
|
|
|
Print a variable that contains your first name
Use: variables[1]
|
|
|
|
Do the sum 27 / 72 in code and store the result
Use: variables[1]
|
|
|
|
|