Code Writer
Level 3, 2025-09-15
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 average of the numbers from 2 to 17
Use: variables, loops[2]
|
|
|
Assume you have a non-empty list E. Create a new variable that is equal to the first element in the list.
Use: variables[1]
|
|
Test Using: E = [1] E = ['a','b','c'] E = [50,42,73] |
A rectangle has sides of 3 and 4. Create variables for the sides of the shape and then calculate its area
Use: variables[2]
|
|
|
Create a list containing 2 numbers
Use: variables[1]
|
|
|
Assume you have a non-empty list B. Print the first element in the list.
Use: variables[1]
|
|
Test Using: B = [1] B = ['b','a','c'] B = [36,89,84] |
Assume you have a variable B. If B is bigger than 2 print "big", otherwise print "small"
Use: variables, if[2]
|
|
Test Using: B = 0 B = 5 B = 10 |
Print each number from 2 to 8
Use: loops[2]
|
|
|
Assume you have a list variable LIST. Print each value in LIST.
Use: loops[2]
|
|
Test Using: LIST = [1,2,3] LIST = ['a','b',0] LIST = [] |
Assume you have a non-empty list of numbers Z. Write code to find the smallest number in the list.
Use: variables, loops, if[2]
|
|
Test Using: Z = [1,2,3] Z = [3,2,1,0] Z = [31,16,80] |
|