Menu

Python Programming (Turtle)

Card 1 of 74 0 got it 0 still learning
Question
TapClick or press space to see the answer
Answer
All 74 cards in this set
Which command makes the turtle move ahead by 100 pixels and draw a line as it goes?
Turtle.forward(100)
What is meant by turtle.pendown()?
It puts the pen back down so the turtle draws a line again
What does turtle.right(90) do?
It turns the turtle 90 degrees clockwise without moving it
In turtle graphics, what name is given to the angle the turtle turns through at each corner of a regular shape?
Exterior angle
Which line must be at the top of a Python file so that Turtle commands work?
Import turtle
In Python Turtle, what happens on the screen as the turtle moves?
It draws a line behind the turtle
What does turtle.backward(50) make the turtle do?
Move 50 pixels backwards and draw a line
A regular hexagon is drawn with the turtle. What angle should the turtle turn at each corner?
60 degrees
Which rule gives the angle the turtle turns at each corner of a regular shape?
Divide 360 by the number of sides
What does turtle.penup() do?
Lifts the pen so the turtle moves without drawing
A student has drawn one square and wants to move the turtle to a new place to draw a second square that does not touch the first. Which pair of commands should be used around the movement?
Turtle.penup() then turtle.pendown()
What does the command turtle.speed(10) change?
How quickly the turtle draws
Which command changes the way the turtle is shown on the screen?
Turtle.shape('turtle')
A Python program uses turtle commands but import turtle is missing from the top of the file. What happens when the program is run?
Python reports an error because it does not know turtle
A turtle is facing the top of the screen. It runs turtle.left(90). Which way is it facing now?
Towards the left side of the screen
A student has turtle.speed(10) near the top of their program and the shape appears too quickly to watch. What should they change?
Use a lower number for the speed
What does this program draw?
Two sides meeting at a corner
A regular shape is drawn with the turtle turning 72 degrees at each corner. Which shape is it?
A pentagon
A rectangle is drawn with sides of 200 pixels and 500 pixels. What angle does the turtle turn at each corner?
90 degrees
A student uses turtle.penup() to move the turtle to a new place, then draws the next shape without using turtle.pendown(). What happens?
No line is drawn for the next shape
A student draws a square but writes turtle.right(4) at each corner instead of turtle.right(90). What happens on the screen?
The turtle turns only 4 degrees at each corner
Why do we write programs in a language such as Python instead of writing the instructions in English?
Computers cannot understand human languages such as English
A turtle starts in the middle of the screen. Where does the turtle finish after this program runs?
Back at its starting point
A square is drawn by moving forward and turning right(90) at each corner. How many degrees does the turtle turn in total while drawing the square?
360 degrees
Which term describes a block of code that repeats a set number of times, decided before it starts?
Count controlled loop
Which term describes the punctuation mark that must come at the end of the first line of a for loop?
Colon
What is the name for the spaces at the start of a line that show the code belongs inside a loop?
Indentation
In the line for i in range(5):, what does range(5) set?
How many times the indented code is repeated
Which keyword starts a count controlled loop in Python?
For
When a loop draws a regular shape, what name is given to the angle the turtle turns through at each corner?
Exterior angle
Why is a for loop useful when drawing a shape such as a hexagon?
It repeats the same lines instead of copying them
Which line correctly starts a for loop that repeats 4 times?
for i in range(4):
In a for loop, which lines of code are repeated?
The indented lines underneath the for line
To draw a regular shape with a loop, the turn each time should be which value?
360 divided by the number of sides
How many times must a loop repeat to draw a circle using forward(1) and right(1)?
360 times
A loop uses for i in range(2): and turtle.right(90) to draw a square, but only half a square is drawn. What is the fix?
Change range(2) to range(4)
A loop is written with empty brackets, as in range(). What will happen?
Nothing is drawn because no repeat count is given
When one loop draws three separate squares, why is penup() used between them?
To move into position without leaving a line
A pupil draws an octagon with for i in range(8): but uses turtle.right(4) inside the loop. The shape comes out wrong. Which turn should be used instead?
45 degrees
A pupil writes for i in range(4) but forgets the colon at the end of the line. What happens when the program runs?
The program stops with an error
Which term describes a named block of code that can be run whenever it is needed?
A subroutine
Which keyword is written at the start of a subroutine definition?
Def
What is meant by calling a subroutine?
Writing the name of the subroutine with brackets so the code inside it runs
Which term describes the pair of round symbols that must be written after a subroutine name at the end of the def line and again each time it is called?
Brackets
What is meant by defining a subroutine?
Writing a def line and the code that belongs to it
Which symbol must come at the end of the def line, after the brackets?
A colon
In the line def draw_star():, what is the name of the subroutine?
draw_star
Which line correctly starts the definition of a subroutine called draw_square?
Def draw_square():
Why is a subroutine useful when a program draws the same shape many times?
It removes repeated code and keeps the program short
A student defines a subroutine that draws a square, then runs the whole program. Nothing is drawn. What is the most likely reason?
The subroutine was defined but never called
A subroutine called draw_circle has already been defined. Which line calls it?
draw_circle()
How many times can a subroutine be called in a program?
As many times as needed, and it runs the same way each time
Why does the code inside a subroutine need to be indented?
It shows Python which lines belong to the subroutine
A subroutine called square contains a for loop that draws one square. What happens when square() is called three times?
Three squares are drawn, one from each call
A subroutine draws a square. A student wants to draw two squares in different places. What must be added between the two calls?
Lift the pen, move the turtle, then put the pen down again
A program defines draw_square(), and later has the line draw_square with no brackets. What happens when the program runs?
The subroutine is not called, so no square is drawn
A subroutine draw_square() draws one square. A student wants to draw four squares in a row. What is the best way to do this without repeating the square code?
Call draw_square() in a loop four times
What happens if the lines of code inside a subroutine are not indented?
They are not part of the subroutine
Which command sets the colour of the lines the turtle draws?
The command pencolor()
What is meant by turtle.fillcolor()?
It sets the colour used to fill the inside of a shape
Which command goes before the lines of a shape to mark where the shape to be filled starts?
The command begin_fill()
What does turtle.end_fill() do?
It closes the shape and fills it with the set colour
Which command changes how thick the lines drawn by the turtle are?
The command pensize()
What is meant by turtle.width()?
It changes how thick the lines are drawn, like pensize
A student types turtle.pencolour('blue') but the lines stay black. Why?
Python only knows the American spelling, pencolor
A student wants to fill a square with red. Which order of steps is correct?
Set the fill colour, begin the fill, draw the square, end the fill
A program draws a square but never calls turtle.end_fill(). What is the result?
The square is drawn but stays unfilled
A student's filled shape has colour leaking outside its edges. What is the most likely cause?
The lines of the shape do not join up
A student wants each side of a square in a different colour. What should they do?
Call pencolor before drawing each side
A student writes turtle.pencolor('grass') to draw green lines. What happens?
Python reports an error, as grass is not a colour
A student builds a tree from a brown rectangle trunk and green triangles. What must they do to colour the shapes correctly?
Set the colour before drawing each shape
A student draws a blue line, then changes the pen colour to red and draws a second line. What colours are the two lines?
The first line is blue and the second is red
A student fills a square with blue, then draws a triangle between begin_fill and end_fill without setting the fill colour again. What happens to the triangle?
It is filled in blue, because the fill colour is still set
A student sets the pen colour to red and the fill colour to blue, then draws a square and fills it. What does the square look like?
It has a red outline and a blue inside