Code Writer
Level 3, 2026-11-29
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 A. Write code to count how many numbers in the list are smaller than 15
Use: variables, loops, if[3]
|
|
|
Test Using: A = [] A = [15,0,25] A = [15,76,55] |
Print each number from 0 to 36
Use: loops[2]
|
|
|
|
Create two strings and join them together with a space between
Use: variables[1]
|
|
|
|
Assume you have a list of numbers X. Print the 8th element of X.
Use: variables[1]
|
|
|
Test Using: X = [1,2,3,4,5,6,7,8,9,10] |
Do the sum 85 / 91 and print the result
Use: [1]
|
|
|
|
A triangle has sides of 6, 7 and 9. Create variables for the sides of the triangle and then calculate its perimeter.
Use: variables[2]
|
|
|
|
Use a loop to print 90 lines with a line number and the word "bloop". For example, line 1 should be "1: bloop", line 2 would be "2: bloop", etc.
Use: variables, loops, str()[2]
|
|
|
|
A list contains numbers that are the amount of HP damage caused by a series of attacks. Your character starts with 127HP. 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] |
|