Code Writer
Level 3, 2026-06-23
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 20 lines with a line number and the word "dumdum". For example, line 1 should be "1: dumdum", line 2 would be "2: dumdum", etc.
Use: variables, loops, str()[2]
|
|
|
|
Use a loop to create a string that has 15 "C" characters
Use: variables, loops[2]
|
|
|
|
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 = [14,31,47] |
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]
|
|
|
|
Assume you have a list of numbers Q. Write code to count how many numbers in the list are smaller than or equal to than 5
Use: variables, loops, if[3]
|
|
|
Test Using: Q = [] Q = [5,0,25] Q = [1,47,69] |
Assume you have a non-empty list Z. Create a new variable that is equal to the first element in the list.
Use: variables[1]
|
|
|
Test Using: Z = [1] Z = ['a','b','c'] Z = [72,56,55] |
Use a loop to add the numbers from 4 to 30
Use: variables, loops[2]
|
|
|
|
Assume you have 2 lists of numbers with 14 elements each: Q and F. Add the 8th elements of the lists together.
Use: variables[1]
|
|
|
Test Using: Q = [1,2,3,...,14], F = [1,2,3,...,14] |
|