17.12. Multiple Choice QuestionsΒΆ
- 1234
- You must first import the turtle module.
- 2341
- You must create a turtle object before you ask it to do things using dot notation.
- 3142
- You must first import the turtle module.
- 2314
- Correct! The turtle module needs to be imported and then a screen needs to be created before creating a turtle object.
11-9-1: What order do these four statements need to appear in to not give any errors?
Statement 1 : alex = Turtle()
Statement 2 : from turtle import *
Statement 3 : space = Screen()
Statement 4 : alex.forward(50)
- L
- Incorrect! Follow every step and try to recreate the shape. Try again.
- A
- Incorrect! Follow every step and try to recreate the shape. Try again.
- T
- Correct! The code would create an T shape.
- H
- Incorrect! Follow every step and try to recreate the shape. Try again.
11-9-2: What letter will this code draw?
from turtle import *
space = Screen()
alex = Turtle()
alex.forward(100)
alex.left(180)
alex.forward(50)
alex.left(90)
alex.forward(150)
- East
- Incorrect! Remember where the turtle initially faces when it is created. Try again.
- South
- Incorrect! Remember where the turtle initially faces when it is created. Try again
- West
- Incorrect! Remember where the turtle initially faces when it is created. Try again.
- North
- Correct! The turtle always start from facing east by default.
11-9-3: Which way does a turtle (object of the Turtle class) face after this code executes?
from turtle import *
space = Screen()
alex = Turtle()
alex.forward(150)
alex.left(180)
alex.forward(75)
alex.right(45)
alex.left(315)
alex.forward(50)
- 4 errors
- Incorrect! Hint: Remember the correct syntax for creating turtles. Try again.
- 7 errors
- Correct! Every row in the code has atleast one problem.
- 6 errors
- Incorrect! Hint: Remember the correct syntax for creating turtles. Try again.
- 5 errors
- Incorrect! Hint: Remember the correct syntax for creating turtles. Try again.
11-9-4: How many errors are present in the following code?
from Turtle Import *
space = Screen
alex = turtle()
alexes.Forward('150')
- 2 lines
- Incorrect! Hint: What do penup() and pendown() do? Try again.
- 3 lines
- Correct! Remember, that due to penup() some lines won't be printed.
- 4 lines
- Incorrect! Hint: What do penup() and pendown() do? Try again.
- 5 lines
- Incorrect! Hint: What do penup() and pendown() do? Try again.
11-9-5: Based on the given code, how many lines will be drawn on the screen?
from turtle import *
space = Screen()
alex = Turtle()
alex.forward(30)
alex.left(90)
alex.penup()
alex.forward(50)
alex.left(90)
alex.pendown()
alex.forward(20)
alex.right(90)
alex.penup()
alex.forward(50)
alex.left(180)
alex.forward(10)
alex.right(30)
alex.pendown()
alex.right(90)
alex.forward(30)
- alex : 5, "Red", james : 4, "Green"
- Incorrect! Follow every step and try to recreate the shape. Try again.
- alex : 10, "Blue", james : 10, "Red"
- Incorrect! Follow every step and try to recreate the shape. Try again.
- alex : 2, "Green", james : 10, "Blue"
- Incorrect! Follow every step and try to recreate the shape. Try again.
- alex : 10, "Red", james : 2, "Green"
- Correct! The given code would have the turtle with these values at the end of the code.
11-9-6: What would be the final pensize and pencolor after this code executes for both the turtles?
from turtle import *
space = Screen()
alex = Turtle()
james = Turtle()
alex.forward(30)
alex.left(90)
alex.color("blue")
alex.pensize(10)
alex.forward(50)
alex.left(90)
alex.color("red")
alex.forward(20)
alex.right(90)
james.pensize(5)
james.forward(50)
james.left(180)
james.forward(10)
james.right(30)
james.pensize(2)
james.right(90)
james.color("green")
james.forward(50)
- (30, 10)
- Incorrect! Follow every step and try to recreate the shape. Also see what goto() does. Try again.
- (10, 30)
- Correct! The turtle is facing west at (30,30) when it goes forward 20 which decreases x to 10.
- (30, 30)
- Incorrect! Follow every step and try to recreate the shape. Also see what goto() does. Try again.
- (50, 30)
- Incorrect! Follow every step and try to recreate the shape. Also see what goto() does. Try again.
11-9-7: What are the final coordinates of the turtle at the end of this code?
from turtle import *
space = Screen()
alex = Turtle()
alex.forward(30)
alex.left(90)
alex.goto(120, 50)
alex.forward(50)
alex.left(90)
alex.goto(30, 30)
alex.forward(20)
alex.right(90)
- The outline of a square in blue
- Incorrect! Think what the .begin_fill() method does. Try again.
- The outline of a rectangle in blue
- Incorrect! Think what the .begin_fill() method does. Try again.
- A blue square
- Incorrect! Look at the height and width parameters of the function. Try again.
- A blue rectangle
- It will draw a filled blue rectangle.
11-9-8: What shape would the following code draw?
from turtle import *
def draw_shape(turtle, xpos, ypos, width, height, color, size):
turtle.penup()
turtle.goto(xpos, ypos)
turtle.pendown()
turtle.color(color)
turtle.pensize(size)
turtle.begin_fill()
for x in range(2):
turtle.forward(width)
turtle.right(90)
turtle.forward(height)
turtle.right(90)
turtle.end_fill()
space = Screen()
alex = Turtle()
draw_shape(alex, 10, 20, 50, 20, 'blue', 5)
- draw_rectangle(alex, 80, 50, -100, 80, 'green', 7)
- Incorrect! The parameters are assigned in order. Try again.
- draw_rectangle(alex, -100, 80, 80, 50, 'green', 7)
- This assigns the parameters correctly.
- draw_rectangle(alex, -100, 80, 80, 50, green, 7)
- Incorrect! The color must be a string.
- draw_rectangle(alex, 80, 100, 80, 50, 'green', 7)
- Incorrect! The xpos is before the ypos.
11-9-9: Given the function below. What parameters would you use to create a green rectangle of pen size 7 with a width 80 and height 50 at location (-100, 80)?
from turtle import *
def draw_rectangle(turtle, xpos, ypos, width, height, color, size):
turtle.penup()
turtle.goto(xpos, ypos)
turtle.pendown()
turtle.color(color)
turtle.pensize(size)
turtle.begin_fill()
for x in range(2):
turtle.forward(width)
turtle.right(90)
turtle.forward(height)
turtle.right(90)
turtle.end_fill()
space = Screen()
alex = Turtle()
- Tree
- Incorrect! Think of what the heading would be for each triangle. Try again.
- Hourglass
- Correct! This is the correct shape that will be printed from this code.
- Diamond
- Incorrect! Think of what the heading would be for each triangle. Try again.
- Rectangle
- Incorrect! Try to draw it yourself.
11-9-10: What is drawn when the following code runs?
from turtle import *
def draw_triangle(turtle, xpos, ypos, width, color, heading):
turtle.penup()
turtle.goto(xpos, ypos)
turtle.setheading(heading)
turtle.pendown()
turtle.color(color)
turtle.begin_fill()
for side in range(3):
turtle.forward(width)
turtle.left(120)
turtle.end_fill()
space = Screen()
alex = Turtle()
draw_triangle(alex, -120, 30, 60, 'green', 60)
draw_triangle(alex, -120, 30, 60, 'green', 240)