Code Writer
Level 3, 2026-10-29
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 variable LIST. Print each value in LIST.
Use: loops[2]
|
|
|
Test Using: LIST = [1,2,3] LIST = ['a','b',0] LIST = [] |
Print a list of strings, including a line number on each line
Use: variables, loops, str()[2]
|
|
|
|
Assume you have 2 lists of numbers with 19 elements each: X and E. Add the 10th elements of the lists together.
Use: variables[1]
|
|
|
Test Using: X = [1,2,3,...,19], E = [1,2,3,...,19] |
Assume you have a non-empty list VAR. Create a new variable that is equal to the first element in the list.
Use: variables[1]
|
|
|
Test Using: VAR = [1] VAR = ['a','b','c'] VAR = [0,28,37] |
Assume you have a list of names, VAR. Write code to count the number of times the name "Jenny" appears in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: VAR = [] VAR = ['Jenny'] VAR = ['Jenny','Mike','Edward','Jenny'] |
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 58!
Use: variables, loops, str()[2]
|
|
|
|
Use a loop to multiply the numbers from 1 to 27
Use: variables, loops[2]
|
|
|
|
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 a list Z with at least 2 elements. Create a new variable that is equal to the first two elements added together.
Use: variables[1]
|
|
|
Test Using: Z = ['a','b','c'] Z = ['big','dog'] Z = [88,2,91] |
|