Code Writer
Level 3, 2026-10-26
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 = [] |
Assume you have a list variable LIST. Count the number of items in LIST and print the result.
Use: loops, variables[2]
|
|
|
Test Using: LIST = ['a','b','c'] LIST = [1,2,3,4,5,6] LIST = [] |
A list contains numbers that are the amount of HP damage caused by a series of attacks. Your character starts with 140HP. 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] |
Use a loop to print 57 lines with a line number and the word "nose". For example, line 1 should be "1: nose", line 2 would be "2: nose", etc.
Use: variables, loops, str()[2]
|
|
|
|
Assume you have a list of numbers X. Create a new variable that is equal to sum of all the numbers in X.
Use: variables, loops[2]
|
|
|
Test Using: X = [] X = [1,1] X = [80,59,85] |
A factorial of a number is all the numbers from 1 to that number multiplied together, so 4! = 1x2x3x4. Write code using a loop to calculate 33!
Use: variables, loops, str()[2]
|
|
|
|
Assume you have a non-empty list of numbers X. Create a new variable that is equal all the numbers in X multiplied together.
Use: variables, loops[2]
|
|
|
Test Using: X = [1,1] X = [1,2,3,4,5] X = [25,75,24] |
|