Code Writer
Level 3, 2026-09-17
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. 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 of numbers Q. Print the 8th element of Q.
Use: variables[1]
|
|
|
Test Using: Q = [1,2,3,4,5,6,7,8,9,10] |
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 79!
Use: variables, loops, str()[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 35!
Use: variables, loops, str()[2]
|
|
|
|
Assume you have a non-empty list of numbers Y. Write code to find the smallest number in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: Y = [1,2,3] Y = [3,2,1,0] Y = [57,32,64] |
Use a loop to print 28 lines with the numbers from 1 to 28 and each number times 14, separated by a commma.
For example, line 1 would be "1, 14", line 2 would be "2, 28",etc.
Use: variables, loops, str()[2]
|
|
|
|
Use a loop to print 47 lines with the numbers from 1 to 47 and each number times 13, separated by a commma.
For example, line 1 would be "1, 13", line 2 would be "2, 26",etc.
Use: variables, loops, str()[2]
|
|
|
|
Assume you have two non-empty lists of numbers Q and E. Create a new variable that is equal to the first element of each list added together.
Use: variables[1]
|
|
|
Test Using: Q = [1], E = [1] Q = [1,2,3], E = [3,2,1] Q = [62,16,18], E = [90,97,2] |
Print a variable that contains your first name
Use: variables[1]
|
|
|
|
|