Code Writer
Level 3, 2026-07-26
Answers should be legal Python code, including indentation. Use the underscore _ to show a space.
Special functions: print(), range(), sqrt(), str()
Assume you have 2 variables S and T that are equal to the sides of a rectangle. Calculate another variable that is equal to the perimeter of the rectangle.
Use: variables[2]
|
|
|
Test Using: S = 45, T = 72 |
A list contains numbers that are the amount of HP damage caused by a series of attacks. Your character starts with 110HP. Write code that works out how much damage you have taken and prints "Dead" if you are killed.
Use: variables, loops, if[3]
|
|
|
Test Using: attacks = [1] attacks = [50,50,50] attacks = [1,1,1] |
Print each number from 1 to 38
Use: loops[2]
|
|
|
|
Use a loop to create a string that has 28 "D" characters
Use: variables, loops[2]
|
|
|
|
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 = [27,94,91] |
Create two strings and join them together with a space between
Use: variables[1]
|
|
|
|
Write a loop that prints "dumbdumb" 18 times
Use: loops[2]
|
|
|
|
A factorial of a number is all the numbers from 1 to that number multiplied together, so 4! = 1x2x3x4. Write code using a loop to calculate 50!
Use: variables, loops, str()[2]
|
|
|
|
|