Code Writer
Level 3, 2026-11-08
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 variable Z. If Z is smaller than 6 add 7 to it, otherwise subtract 8 from it
Use: variables, if[2]
|
|
|
Test Using: Z = 0 Z = 6 Z = 10 |
Assume you have a list of letters E. Write code to count the number of times the letter "g" appears in the list.
Use: variables, loops, if[2]
|
|
|
Test Using: E = [] E = ['g','a','z'] E = ['g','g','g'] |
Assume you have a list of numbers Z. Print the 6th element of Z.
Use: variables[1]
|
|
|
Test Using: Z = [1,2,3,4,5,6,7,8,9,10] |
Set a variable to one value then change that value
Use: variables[1]
|
|
|
|
Use a loop to create a string that has 31 "b" characters
Use: variables, loops[2]
|
|
|
|
A triangle has sides of 8, 4 and 5. Create variables for the sides of the triangle and then calculate its perimeter.
Use: variables[2]
|
|
|
|
Assume you have a list variable LIST of numbers. Use a variable to add the items in the list
Use: variables, loops[2]
|
|
|
Test Using: LIST = [1] LIST = [1,2,3,4,5,6,7,8,9] LIST = [54,64,67] |
Write a loop that prints "fake" 79 times
Use: loops[2]
|
|
|
|
Print your first name
Use: [1]
|
|
|
|
|