Python 🐍 Programming 💻

Topic 1

Creating Turtles 🐢

Do Now

1. How many lines of code?    4    6    8    5

2. What is around the word turtle on line 5?    (    ;    "    *

3. Which on is a colon?    :    ;    .    <

4. On which lines was the TAB key used?
 

5. How can you change the shape from turtle to circle in line 5?

 

import turtle

def task1():
	tina = turtle.Turtle()
    tina.shape("turtle")
    
    
task1()

💻

execute

First look 👀

Ignore the first lines...

 

task1() is a function we define

 

we have to call 📞 task1() to run it 👟

Inside task1()

we create a turtle 🐢 variable called tina

 

tina has a function called shape() ⬛🔴🔺⬆️🐢

The goto() function

tina has a function called goto() which moves her🏃‍♀️‍➡️to given coordinates:

 

goto(150,50)

goto(100,-100)

goto(-50,50)

def task2():
  tina =
  tina.shape( )
  tina.goto( )

task2()

Complete task2() to match the image 📷

Challenge: move to 3 other coordinates

task2()

def task3():
  tina =

task3()

Complete task3() to match the image 📷

Challenge: Discover a new shape

(research "python turtle shapes" online)

task3()

def plenary():
  tina = turtle.
  tina.shape( )
  tina.goto( )
  tina.goto( )
  tina.goto( )

Choose the right options for line 1 and 2
New()    Turtle()    Create()    Start()

turtle    circle    "turtle"    "circle"

🧑‍💻👩‍💻Complete the code to match the image

Topic 2

Turtle Movement

Which function creates a turtle 🐢?

turtle.New()    turtle.Turtle()    turtle.Start()    turtle.Init()

 

What name did we give to our turtle variable?

toby    tarik    tess    tina

 

Select the right shape() function ⬛🔴🔺⬆️🐢:

shape(turtle)    shape("dvd")    shape("turtle")    shape(heart)

 

Challenge: What function moves 🏃‍♀️‍➡️ the turtle to the coordinate x=100 and y=100? 

Do Now

First look

tina has a function called forward() to move by pixels

 

tina has a function called left() to move by degrees

 

Let's finish the square!

Opposite functions!

opposite of forward()?

 

opposite of left()?

 

they work the same way!

 

let's create the opposite_square() function!

triangle()

Complete the code to make the below triangle!

def triangle():
  tina = turtle.Turtle()
  tina.shape("turtle")
  tina.forward( )
  tina.left( )

120

60

pentagon()

Complete the code to make the below pentagon!

def pentagon():
  tina = 
  tina.shape("turtle")

72

108

Tic Tac Toe Field

penup(): function to stop drawing

pendown() function to start drawing

Complete the field!

(-150,50)

(-150,-50)

(-50,-150)

(50,-150)

Plenary

Solve the maze...

# Use these
hero.forward(50)
hero.backward(50)
hero.left(90)
hero.right(90)

Topic 3

Multiple Turtles

Select a valid 🐢 goto() function:

goto(100)    goto(-50)    goto(-50,-150)    goto(100,-50,50)

 

Select a valid 🏃‍♀️‍➡️ forward() function:

shape(turtle)    shape("dvd")    shape("turtle")    shape(heart)

 

The right(180) function would make a 🐢 turn?

 

 

Challenge: Predict the function to change the colour of a turtle.

Do Now

Teenage Mutant Ninja Turtles

name and color

Raffaele

Red

Donatello

Purple

Michelangelo

Orange

Leonardo

Blue

New functions

color(): function to change color

write(): function to write text 📄

 

what happens if we remove the penup() 🖊️ function?

(0,0)

Let's add donatello

(0,0)

donatello = turtle.Turtle()
donatello.shape("turtle")
donatello.color(" ")
donatello.penup()
donatello.goto( )
donatello.left( )
donatello.write("      Donatello")

michelangelo and leonardo

(0,0)

michelangelo = turtle.Turtle()
michelangelo.shape("turtle")
michelangelo.color("orange")

leonardo = turtle.Turtle()
leonardo.shape("turtle")
leonardo.color("blue")

Copy the code and complete to match the image

while True:
  raffaele.forward(10)
  raffaele.delay(100)

An infinite loop ♾️ in python repeats code forever!

 

 

 

 

code inside the loop must be 🫸 indented to be repeated.

 

delay() pauses milliseconds ⌛

Infinite loop

while True:
  raffaele.forward(10)
  raffaele.delay(100)

Complete to match the gif!

Disperse! 🍃

python&turtle

By Jakob Stanley Warth

python&turtle

  • 55