Code Writer
Level 3, 2026-08-31
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 of numbers A. Print the 5th element of A.
Use: variables[1]
|
|
|
Test Using: A = [1,2,3,4,5,6,7,8,9,10] |
Use a loop to print 35 lines with the numbers from 1 to 35 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]
|
|
|
|
Create two strings and join them together with a space between
Use: variables[1]
|
|
|
|
Assume you have a list of numbers A. Write code to count how many numbers in the list are smaller than or equal to than 18
Use: variables, loops, if[3]
|
|
|
Test Using: A = [] A = [18,0,25] A = [87,26,70] |
Assume you have a non-empty list of numbers E. Create a new variable that is equal all the numbers in E multiplied together.
Use: variables, loops[2]
|
|
|
Test Using: E = [1,1] E = [1,2,3,4,5] E = [45,38,9] |
Assume you have a list of names, Z. Write code to count the number of times the name "Mongo" appears in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: Z = [] Z = ['Mongo'] Z = ['Mongo','Edward','Jenny','Mongo'] |
Assume you have a list of numbers Y. Write code to add up the numbers in the list that are smaller than 13
Use: variables, loops, if[3]
|
|
|
Test Using: Y = [] Y = [5,6,7,8,9,10,11,12,13,14,15] Y = [65,37,71] |
Print a variable that contains your first name
Use: variables[1]
|
|
|
|
|