Code Writer
Level 3, 2026-09-10
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. Print each value in LIST.
Use: loops[2]
|
|
|
Test Using: LIST = [1,2,3] LIST = ['a','b',0] LIST = [] |
A right angled triangle has 2 shorter sides of 5 and 1. Calculate the other side (the "hypotenuse").
Use: variables, sqrt()[2]
|
|
|
|
Use a loop to print the sum of the numbers from 0 to 4
Use: variables, loops[2]
|
|
|
|
A right angled triangle has 2 shorter sides of 8 and 7. Calculate the other side (the "hypotenuse").
Use: variables, sqrt()[2]
|
|
|
|
Assume you have a list of numbers E. Write code to count how many numbers in the list are bigger than 2
Use: variables, loops, if[3]
|
|
|
Test Using: E = [] E = [2,0,25] E = [19,96,47] |
Assume you have a list of letters Q. Write code to count the number of times the letter "D" appears in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: Q = [] Q = ['D','a','z'] Q = ['D','D','D'] |
Assume you have 2 lists of numbers with 13 elements each: Y and Q. Add the 7th elements of the lists together.
Use: variables[1]
|
|
|
Test Using: Y = [1,2,3,...,13], Q = [1,2,3,...,13] |
Assume you have a list A with at least 2 elements. Create a new variable that is equal to the first two elements added together.
Use: variables[1]
|
|
|
Test Using: A = ['a','b','c'] A = ['big','dog'] A = [59,49,26] |
|