Code Writer
Level 3, 2026-11-04
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 names, F. Write code to count the number of times the name "Melissa" appears in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: F = [] F = ['Melissa'] F = ['Melissa','Mike','Missy','Melissa'] |
Create a function that duplicates a string. It has two arguments: the string to duplicate and a number that is how many times to duplicate. It returns the duplicated string. For example the string "dog" duplicated twice returns "dogodog".
Use: variables, functions[2]
|
|
|
Test Using: String = 'sus' String = '' String = 'hi you' |
Do the sum 76 + 37 in code and store the result
Use: variables[1]
|
|
|
|
Assume you have 2 lists of numbers with 14 elements each: Q and E. Add the 6th elements of the lists together.
Use: variables[1]
|
|
|
Test Using: Q = [1,2,3,...,14], E = [1,2,3,...,14] |
Assume you have a list of numbers VAR. Write code to count the number of times the number 82 appears in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: VAR = [82] VAR = [0,82,-1,82,99,82] VAR = [5,51,34] |
Assume you have a list of letters F. Write code to count the number of times the letter "f" appears in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: F = [] F = ['f','a','z'] F = ['f','f','f'] |
Use a loop to print the sum of the numbers from 8 to 19
Use: variables, loops[2]
|
|
|
|
Create a list containing 5 colors and then print each one
Use: variables, loops[2]
|
|
|
|
Create a list containing 5 colors
Use: variables[1]
|
|
|
|
|