Code Writer
Level 3, 2026-02-11
Answers should be legal Python code, including indentation. Use the underscore _ to show a space.
Special functions: print(), range(), sqrt(), str()
Print a variable that contains your first name
Use: variables[1]
|
|
|
|
Assume you have a non-empty list of numbers VAR. Write code to find the biggest number in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: VAR = [1,2,3] VAR = [3,2,1,0] VAR = [74,3,45] |
Print each number from 0 to 48
Use: loops[2]
|
|
|
|
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 = [] |
Use a loop to print 42 lines with a line number and the word "moo". For example, line 1 should be "1: moo", line 2 would be "2: moo", etc.
Use: variables, loops, str()[2]
|
|
|
|
A list contains a series of attacks on an enemy. The list looks like [1,2,3,1,1,2,...] where each element in the list is a number that means a type of attack:
1 is a light attack, taking 3HP 2 is a medium attack taking 6HP 3 is a strong attack taking 13HP
Write code to calculate the total amount of HP damage caused by all the attacks.
Use: variables, loops, if[3]
|
|
|
Test Using: attacks = [1,2,3] attacks = [1,2,3,3,2,1] attacks = [33,5,42] |
Create two strings and join them together with a space between
Use: variables[1]
|
|
|
|
Use a loop to print a list of numbers, including a line number on each line
Use: variables, loops, str()[2]
|
|
|
|
|