Code Writer
Level 3, 2026-10-06
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 variable S that is the length of the side of a square. Calculate another variable that is equal to the perimeter of the square.

Use: variables[2]

Test Using:
S = 59
Print a variable that contains your first name

Use: variables[1]
Assume you have a list variable LIST. Count the number of items in LIST.

Use: loops, variables[2]

Test Using:
LIST = ['a','b','c']
LIST = [1,2,3,4,5,6]
LIST = []
Create a function that duplicates a string. It has two arguments: the string to duplicate and a number that is how many times to duplicate. It returns the duplicated string. For example the string "dog" duplicated twice returns "dogodog".

Use: variables, functions[2]

Test Using:
String = 'sus'
String = ''
String = 'hi you'
Assume you have a variable Y. If Y is smaller than 3 add 3 to it, otherwise subtract 2 from it

Use: variables, if[2]

Test Using:
Y = 0
Y = 3
Y = 10
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 2HP
2 is a medium attack taking 4HP
3 is a strong attack taking 9HP

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 = [74,26,64]
Print each number from 1 to 22

Use: loops[2]
Assume you have 2 lists of numbers with 5 elements each: X and Y. Add the 4th elements of the lists together.

Use: variables[1]

Test Using:
X = [1,2,3,...,5], Y = [1,2,3,...,5]