Code Writer
Level 3, 2026-04-22
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 35 lines with the numbers from 1 to 35 and each number times 17, separated by a commma.
For example, line 1 would be "1, 17", line 2 would be "2, 34",etc.
Use: variables, loops, str()[2]
|
|
|
|
Assume you have two non-empty lists of numbers X and B. Create a new variable that is equal to the first element of each list added together.
Use: variables[1]
|
|
|
Test Using: X = [1], B = [1] X = [1,2,3], B = [3,2,1] X = [25,1,92], B = [58,33,69] |
Use a loop to add the numbers from 2 to 20
Use: variables, loops[2]
|
|
|
|
Create two strings and join them together with a space between
Use: variables[1]
|
|
|
|
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 = [42,87,98] |
Assume you have a variable S that is the length of the side of a square. Calculate another variable that is equal to the area of the square.
Use: variables[2]
|
|
|
Test Using: S = 47 |
Use a loop to multiply the numbers from 7 to 18
Use: variables, loops[2]
|
|
|
|
Set a variable to one value then change that value
Use: variables[1]
|
|
|
|
Create a list containing 4 numbers
Use: variables[1]
|
|
|
|
|