Code Writer
Level 3, 2026-02-13
Answers should be legal Python code, including indentation. Use the underscore _ to show a space.
Special functions: print(), range(), sqrt(), str()
Assume you have 2 lists of numbers that are the same size: E and Z. Count how many times an element in E is smaller than or equal to the element in the same position in Z.
Use: variables, loops[2]
|
|
|
Test Using: E = [5], Z = [5] E = [1,2,3], Z = [3,2,1] E = [11,34,96], Z = [72,44,1] |
Use a loop to print 13 lines with the numbers from 1 to 13 and each number times 16, separated by a commma.
For example, line 1 would be "1, 16", line 2 would be "2, 32",etc.
Use: variables, loops, str()[2]
|
|
|
|
Set two variables to different values then add them together
Use: variables[1]
|
|
|
|
Do the sum 26 + 96 and print the result
Use: [1]
|
|
|
|
A right angled triangle has a hypotenuse (longest side, opposite the right angle) of 13 and another side of 4. Calculate the length of the missing side.
Use: variables, sqrt()[2]
|
|
|
|
Assume you have a list of letters E. Write code to count the number of times the letter "g" appears in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: E = [] E = ['g','a','z'] E = ['g','g','g'] |
Print your first name
Use: [1]
|
|
|
|
Assume you have a variable F. If F is bigger than 5 print "big", otherwise print "small"
Use: variables, if[2]
|
|
|
Test Using: F = 0 F = 5 F = 10 |
Assume you have a list Q with at least 2 elements. Create a new variable that is equal to the first two elements added together.
Use: variables[1]
|
|
|
Test Using: Q = ['a','b','c'] Q = ['big','dog'] Q = [8,35,74] |
Create a list containing 2 colors
Use: variables[1]
|
|
|
|
|