Code Writer
Level 3, 2026-10-30
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 letters X. Write code to count the number of times the letter "B" appears in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: X = [] X = ['B','a','z'] X = ['B','B','B'] |
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 15HP
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 = [19,41,1] |
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 = [] |
Do the sum 92 + 29 in code and store the result
Use: variables[1]
|
|
|
|
A rectangle has sides of 7 and 2. Create variables for the sides of the shape and then calculate its area
Use: variables[2]
|
|
|
|
Print each number from 9 to 19
Use: loops[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 2HP 2 is a medium attack taking 4HP 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 = [19,41,1] |
|