NEW
Font size
WorksheetsPython
Total questions: 25
Worksheet time: 50mins
When the following for loop is complete, how many spaces will Tracy have moved?
50 spaces
60 spaces
10 spaces
5 spaces
Suppose you write a function. How many times can you call the function in your code?
Once
Not more than the number of commands the function holds
It depends on the function
As many times as you want
In which of the following situations would it be best to make a function?
You want Tracy to draw a blue line, and your program requires lots of blue lines.
You need Tracy to move forward by 100.
You need Tracy to turn right and then turn left.
You need to change Tracy’s color.
Which of the following pieces of code will make Tracy do the following actions three times: go forward, change colors, and then turn around.
Suppose you want to make Tracy draw a mountain range, like the one shown below, starting from the left side. Which of the following functions would be the most useful function to write in order to solve this problem?
# Has Tracy draw a single triangle
def make_triangle():
# Change's Tracy's color to red
def change_to_red():
# Moves Tracy forward by 100
def move_100():
# Draws a square
def my_function():
Which of the following is NOT a command you can give to Tracy?
color
turn
backward
left
Which of the statements below is true about indentation in Python?
Indentation only matters in for loops. Then, everything must be indented one level.
Indentation never matters in Python. You can align your code any way you like, but indentation makes your code easier to read.
Indentation always matters in Python. Every statement must be aligned correctly.
Indentation only matters in functions. Then, everything must be indented one level.
Which of the following statements are true about for loops?
I. By default, the range function starts at 0
II. Using for i in range(4) will result in i taking the values 0, 1, 2, 3, 4
III. For loops let you repeat something any number of times
IV. Statements in a for loop do not need to be indented
V. It is not possible to have the range value count 6, 12, 18, 24
VI. It is not possible to have the range values count 1, 2, 4, 8, 16
I, III, VI
I, II, III, VI
I, II, III, V, VI
I, III
Which of the following functions is declared correctly?
Which of the following is NOT a purpose of using functions?
Functions let Tracy do new things.
Functions help group statements together to make your code more readable.
Functions let you execute code a fixed number of times.
Functions allow the programmer to reuse code.
What is the difference between defining and calling a function?
Defining a function means you are teaching the computer a new word. Calling a function means you are commanding the computer to complete defined actions.
There is no difference.
Calling a function means you are teaching the computer a new word. Defining a function means you are commanding the computer to complete defined actions.
Defining a function must be done each time you want to use the function. Calling a function can only happen once in your code.
What does the number in the parentheses in a forward or backward command represent?
How many degrees Tracy is supposed to turn
How fast Tracy is supposed to move
How many times Tracy should repeat the command
How far Tracy is supposed to move
What control structure would be best to use in the following code?
A function
A while loop
A for loop
An if/else statement
Which of the following commands can be used to turn Tracy to face North if she is initially facing South?
left(90)
right(90)
right(180)
right(90)
left(180)
left(360)
Which program below includes no errors?
Which of the following commands can NOT be used to draw one square?
What shape will be drawn with the following command?
circle(50, 360, 3)
A circle
A hexagon
A triangle
A diamond
How can we use variable to control the size of a circle?
radius = 50
circle(radius)
radius = circle(50)
circle(radius)
radius = 50
radius = 50
circle(50)
Can a user’s input control the size of a circle? If so, how?
No, user input is a string.
Yes
circle(user_input=50)
Yes
radius = int(input("Radius: "))
circle(radius)
Yes
radius = input("Radius: ")
circle(radius)
What is the most effective way to draw three circles in a row of different colors?
What will be the output of the following program?
Three circles with radii of 3, 7 and 2.
Three shapes- a triangle (3 sides), a heptagon (7 sides), and a line (2 sides).
Three shapes- a triangle (3 sides), a pentagon (5 sides), and a heptagon (7 sides).
Two shapes- a triangle (3 sides) and a pentagon (5 sides).
What will be the radii of the circles drawn from the following code?
10, 20, 30, 40, 50
10, 15, 20, 25, 30, 35, 40, 45, 50, 55
10, 55, 10
10, 20, 30, 40, 50, 55
Which command will Tracy perform when given the following code?
forward(200)
backward(200)
forward(201)
backward(201)
Which command will Tracy perform when given the following code?
forward(10)
backward(10)
backward(10)
circle(10)
circle(10)
What will be the output of the following code?
5 circles in a row
4 circles in a row
A slinky with 5 circles
An infinite loop will occur
