Code Writer
Level 3, 2026-03-01
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 E with at least 2 elements. Create a new variable that is equal to the first two elements added together.

Use: variables[1]

Test Using:
E = ['a','b','c']
E = ['big','dog']
E = [61,10,71]
Use a loop to print a list of numbers, including a line number on each line

Use: variables, loops, str()[2]
Assume you have a list of numbers E. Create a new variable that is equal to sum of all the numbers in E.

Use: variables, loops[2]

Test Using:
E = []
E = [1,1]
E = [19,65,76]
Assume you have 2 lists of numbers with 13 elements each: Q and X. Add the 10th elements of the lists together.

Use: variables[1]

Test Using:
Q = [1,2,3,...,13], X = [1,2,3,...,13]
Assume you have a list of letters Z. Write code to count the number of times the letter "g" appears in the list.

Use: variables, loops, if[2]

Test Using:
Z = []
Z = ['g','a','z']
Z = ['g','g','g']
Use a loop to print 54 lines with a line number and the word "dumdum". For example, line 1 should be "1: dumdum", line 2 would be "2: dumdum", 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 1HP
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 = [89,48,63]
Print each number from 0 to 44

Use: loops[2]