Code Writer
Level 3, 2026-11-10
Answers should be legal Python code, including indentation. Use the underscore _ to show a space.
Special functions: print(), range(), sqrt(), str()
Print a variable that contains your first name
Use: variables[1]
|
|
|
|
A triangle has sides of 3, 6 and 8. Create variables for the sides of the triangle and then calculate its perimeter.
Use: variables[2]
|
|
|
|
Assume you have 2 lists of numbers with 14 elements each: E and B. Add the 8th elements of the lists together.
Use: variables[1]
|
|
|
Test Using: E = [1,2,3,...,14], B = [1,2,3,...,14] |
A factorial of a number is all the numbers from 1 to that number multiplied together, so 4! = 1x2x3x4. Write code using a loop to calculate 25!
Use: variables, loops, str()[2]
|
|
|
|
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 numbers X. Write code to add up the numbers in the list that are smaller than or equal to than 10
Use: variables, loops, if[3]
|
|
|
Test Using: X = [] X = [5,6,7,8,9,10,11,12,13,14,15] X = [29,67,57] |
A rectangle has sides of 3 and 8. Create variables for the sides of the shape and then calculate its perimeter
Use: variables[2]
|
|
|
|
Print each number from 3 to 16
Use: loops[2]
|
|
|
|
|