Unit 2 Flashcards

By the end of the unit, you will be able to: Use the functions in Python’s built-in drawing library (turtle) to draw a variety of colourful lines and simple shapes that combine to reproduce a graphical image.

1
Q

What is a module?

A

A module provides a set of useful code to be used by another program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the use of the turtle module?

A

The turtle module allows you to draw objects using Python.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Before we can do anything with the turtle module, we ___________.

A

Before we can do anything with the turtle module, we need to import it. Open up IDLE and type in: import turtle
After you‘ve typed that in, press “enter”. This tells Python that you want to use the turtle module.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the two lines of code to import turtle?

A

import turtle
t=turtle.Pen()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What happens when you press enter after typing these lines of code:
import turtle
t=turtle.Pen()

A

You should see the drawing canvas pop up. The turtle might look like just a black triangle, but that’s your turtle.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Why is the black triangle called a turtle even though it does not look like one?

A

It is because it is a reference to the Logo programming language, which has been helping kids learn programming for a very long time - over 50 years!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Can you change the appearance of the turtle?

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you change the shape of the turtle into a circle?

A

import turtle
t= turtle.Pen ()
t.shape (“circle”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you change the shape of the turtle into a turtle?

A

import turtle
t=turtle.Pen()
t.shape (“turtle”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the different shapes that you can change the turtle into?

A

Arrow
Turtle
Circle
Square
Triangle
Classic

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the correct way to create a turtle object named fred?

A

fred= turtle.Pen()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

When we are entering numbers for our turtle to move, the unit we are using is ______.

A

The unit we are using is pixels. These are the tiny dots that your computer screen is made up of. You might have heard of a term called the “resolution” of your monitor, which could be something like 2304 by 1440. That means that the computer monitor has 2304 pixels the long way and 1440 pixels the short way. So pixels are pretty tiny!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you move a turtle forward?

A

t.forward(30)
Let’s say if you want to move the turtle forward by 30 pixels
When the turtle moves, there will be a black line (by default) connecting from where it began to where it is now.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you move the turtle backward?

A

t.backward(30)
This command makes the turtle go back to where it came.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Let say the turtle is the shape of an arrow. Which direction would the arrow of the turtle be facing when there is a command to move it backwards?

A

The arrow will look like that
>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does the left and right command do?

A

The left and right command rotates your turtle. They don’t have it move forward at all. The left and right commands work in degrees not in pixels.

17
Q

Where would the turtle be after these lines of code?
import turtle
t= turtle.Pen ()
t.forward (30)
t.backward (30)
t.left (30)
t.forward (30)

A

/__
Something like that but the lines are connected.
The line is slanted because of the command t.left (30) so 30 is the angle.

18
Q

The direction of the turtle arrow would always be at the right side. Is that true or false?

A

True

19
Q

What is the clear function?

A

The clear() function removes the line that you were drawing, but it leaves the turtle right where it is.

20
Q

What is the reset function?

A

The reset() function also removes the line that you were drawing, but puts the turtle back in the Center of the screen.

21
Q

Can you figure out how to draw a square using by using t= turtle.Pen() ?

A

Square= turtle.Pen ()
Square.forward(40)
Square.right (90)
Square.forward (40)
Square.right (90)
Square.forward (40)
Square.right (90)
Square.forward (40)