Code Writer
Level 3, 2026-06-29
Answers should be legal Python code, including indentation. Use the underscore _ to show a space.
Special functions: print(), range(), sqrt(), str()
Use a loop to print the sum of the numbers from 0 to 5
Use: variables, loops[2]
|
|
|
|
Assume you have a non-empty list F. Create a new variable that is equal to the first element in the list.
Use: variables[1]
|
|
|
Test Using: F = [1] F = ['a','b','c'] F = [54,56,74] |
Use a loop to add the numbers from 0 to 38
Use: variables, loops[2]
|
|
|
|
Use a loop to print a list of numbers, including a line number on each line
Use: variables, loops, str()[2]
|
|
|
|
Set two variables to different strings then make a new variable that combines them with a "g" in between
Use: variables[1]
|
|
|
|
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 = 42 |
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 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 = [89,15,45] |
Assume you have a list F with at least 2 elements. Create a new variable that is equal to the first two elements added together.
Use: variables[1]
|
|
|
Test Using: F = ['a','b','c'] F = ['big','dog'] F = [19,29,43] |
Create two strings and join them together with a space between
Use: variables[1]
|
|
|
|
|