Code Writer
Level 3, 2026-05-19
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 of numbers Q. Print the 4th element of Q.
Use: variables[1]
|
|
|
Test Using: Q = [1,2,3,4,5,6,7,8,9,10] |
Assume you have a non-empty list Q. Print the first element in the list.
Use: variables[1]
|
|
|
Test Using: Q = [1] Q = ['b','a','c'] Q = [91,84,63] |
Print each number from 1 to 47
Use: loops[2]
|
|
|
|
Assume you have 2 lists of numbers with 14 elements each: VAR and Q. Add the 10th elements of the lists together.
Use: variables[1]
|
|
|
Test Using: VAR = [1,2,3,...,14], Q = [1,2,3,...,14] |
Assume you have a list of letters A. Write code to count the number of times the letter "A" appears in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: A = [] A = ['A','a','z'] A = ['A','A','A'] |
A list contains numbers that are the amount of HP damage caused by a series of attacks. Your character starts with 104HP. Write code that works out how much damage you have taken and prints "Dead" if you are killed.
Use: variables, loops, if[3]
|
|
|
Test Using: attacks = [1] attacks = [50,50,50] attacks = [1,1,1] |
A triangle has sides of 9, 7 and 7. Create variables for the sides of the triangle and then calculate its perimeter.
Use: variables[2]
|
|
|
|
Print your first name
Use: [1]
|
|
|
|
Print each number from 1 to 14
Use: loops[2]
|
|
|
|
|