Code Writer
Level 3, 2026-10-22
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 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 = [3,97,11] |
Assume you have 2 lists of numbers with 14 elements each: A and E. Add the 8th elements of the lists together.
Use: variables[1]
|
|
|
Test Using: A = [1,2,3,...,14], E = [1,2,3,...,14] |
Print each number from 0 to 48
Use: loops[2]
|
|
|
|
Set two variables to different values then add them together
Use: variables[1]
|
|
|
|
Use a loop to print 49 lines with the numbers from 1 to 49 and each number times 20, separated by a commma.
For example, line 1 would be "1, 20", line 2 would be "2, 40",etc.
Use: variables, loops, str()[2]
|
|
|
|
Assume you have a non-empty list of numbers E. Write code to find the biggest number in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: E = [1,2,3] E = [3,2,1,0] E = [17,66,85] |
Write a loop that prints "error" 28 times
Use: loops[2]
|
|
|
|
Print a variable that contains your first name
Use: variables[1]
|
|
|
|
Assume you have a list variable LIST. Count the number of items in LIST and print the result.
Use: loops, variables[2]
|
|
|
Test Using: LIST = ['a','b','c'] LIST = [1,2,3,4,5,6] LIST = [] |
Assume you have two non-empty lists of numbers Y and Q. Create a new variable that is equal to the first element of each list added together.
Use: variables[1]
|
|
|
Test Using: Y = [1], Q = [1] Y = [1,2,3], Q = [3,2,1] Y = [41,62,65], Q = [56,60,51] |
|