Code Writer
Level 3, 2026-07-21
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 X with at least 2 elements. Create a new variable that is equal to the first two elements added together.
Use: variables[1]
|
|
|
Test Using: X = ['a','b','c'] X = ['big','dog'] X = [72,63,34] |
Assume you have a non-empty list of numbers Q. Write code to find the smallest number in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: Q = [1,2,3] Q = [3,2,1,0] Q = [79,18,22] |
Create two strings and join them together with a space between
Use: variables[1]
|
|
|
|
Create a list containing 5 colors
Use: variables[1]
|
|
|
|
Assume you have a list of numbers Z. Create a new variable that is equal to sum of all the numbers in Z.
Use: variables, loops[2]
|
|
|
Test Using: Z = [] Z = [1,1] Z = [11,58,12] |
Do the sum 37 + 24 and print the result
Use: [1]
|
|
|
|
Assume you have a list variable LIST. Count the number of items in LIST.
Use: loops, variables[2]
|
|
|
Test Using: LIST = ['a','b','c'] LIST = [1,2,3,4,5,6] LIST = [] |
Assume you have a non-empty list of numbers A. Create a new variable that is equal all the numbers in A multiplied together.
Use: variables, loops[2]
|
|
|
Test Using: A = [1,1] A = [1,2,3,4,5] A = [21,66,11] |
Use a loop to print 61 lines with a line number and the word "dum". For example, line 1 should be "1: dum", line 2 would be "2: dum", etc.
Use: variables, loops, str()[2]
|
|
|
|
Set two variables to different strings then make a new variable that combines them with a "f" in between
Use: variables[1]
|
|
|
|
|