Code Writer
Level 3, 2026-12-05
Answers should be legal Python code, including indentation. Use the underscore _ to show a space.
Special functions: print(), range(), sqrt(), str()
Print each number from 1 to 20
Use: loops[2]
|
|
|
|
Print a variable that contains your first name
Use: variables[1]
|
|
|
|
Assume you have 2 lists of numbers with 19 elements each: Z and Q. Add the 10th elements of the lists together.
Use: variables[1]
|
|
|
Test Using: Z = [1,2,3,...,19], Q = [1,2,3,...,19] |
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 = 70 |
Assume you have a variable Z. If Z is bigger than 5 print "big", otherwise print "small"
Use: variables, if[2]
|
|
|
Test Using: Z = 0 Z = 5 Z = 10 |
A triangle has sides of 3, 7 and 3. Create variables for the sides of the triangle and then calculate its perimeter.
Use: variables[2]
|
|
|
|
Assume you have two non-empty lists of numbers A and F. Create a new variable that is equal to the first element of each list added together.
Use: variables[1]
|
|
|
Test Using: A = [1], F = [1] A = [1,2,3], F = [3,2,1] A = [6,13,72], F = [46,93,35] |
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 67 lines with the numbers from 1 to 67 and each number times 11, separated by a commma.
For example, line 1 would be "1, 11", line 2 would be "2, 22",etc.
Use: variables, loops, str()[2]
|
|
|
|
|