Code Writer
Level 2, 2024-11-25
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 F. If F is bigger than 3 print "big", otherwise print "small"
Use: variables, if[2]
|
|
Test Using: F = 0 F = 5 F = 10 |
Assume you have a list variable LIST. Count the number of items in LIST.
Use: loops, variables[2]
|
|
Test Using: LIST = ['a','b','c'] LIST = [1,2,3,4,5,6] LIST = [] |
Print a variable that contains your first name
Use: variables[1]
|
|
|
Assume you have a list E with at least 2 elements. Create a new variable that is equal to the first two elements added together.
Use: variables[1]
|
|
Test Using: E = ['a','b','c'] E = ['big','dog'] E = [22,64,40] |
Assume you have a non-empty list X. Print the first element in the list.
Use: variables[1]
|
|
Test Using: X = [1] X = ['b','a','c'] X = [49,35,24] |
Set two variables to different values then add them together
Use: variables[1]
|
|
|
A rectangle has sides of 2 and 9. Create variables for the sides of the shape and then calculate its perimeter
Use: variables[2]
|
|
|
Assume you have 2 variables S and T that are equal to the sides of a rectangle. Calculate another variable that is equal to the area of the rectangle.
Use: variables[2]
|
|
Test Using: S = 14, T = 75 |
Print your first name
Use: [1]
|
|
|
Assume you have a variable F. If F is bigger than 2 print "big", otherwise print "small"
Use: variables, if[2]
|
|
Test Using: F = 0 F = 5 F = 10 |
|