0% found this document useful (0 votes)
4 views4 pages

SDF -Week 10

The document outlines a software development fundamentals course focused on turtle graphics in Python, including creating and manipulating turtle objects. It provides code examples demonstrating turtle movements, loops, and shapes. Additionally, it references tutorials for further instructions and examples related to turtle graphics.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

SDF -Week 10

The document outlines a software development fundamentals course focused on turtle graphics in Python, including creating and manipulating turtle objects. It provides code examples demonstrating turtle movements, loops, and shapes. Additionally, it references tutorials for further instructions and examples related to turtle graphics.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

4/12/2024

Software Development Fundamentals


Week 10

Dr. Loubna Mekouar

Note:
• Some of the slides of the course are based on the material provided
by the College of Technological Information, Zayed University, UAE.
• The copyrighted material belongs to their respective owners.

1
4/12/2024

Create a Turtle
• The use of turtle graphics is an interesting application of using loops.

• Creating a turtle graph


• Test this Python Program

import turtle # Allows us to use turtles

window = turtle.Screen() # Creates a playground for the turtle


mat = turtle.Turtle() # Create a turtle
mat.shape("turtle") # Create a shape
mat.color("blue") # Select the turtle color
window.mainloop() # Pause the Window

Turtle Moves
import turtle # Allows us to use turtles

# Create Window
window = turtle.Screen() # Creates a playground for turtle

# Create Turtle
mat = turtle.Turtle()
mat.shape("turtle")
mat.color("blue")

# Move Turtle
mat.forward(50)
mat.left(90)
mat.forward(50)
mat.circle(50)

window.mainloop()
4

2
4/12/2024

Turtle Loops
import turtle

# Create Window
window = turtle.Screen()

# Create Turtle
sam = turtle.Turtle()
sam.shape("turtle")

# Loop Turtle
loopCount = 1
while loopCount <= 12:
sam.left(30) # Final moves
sam.forward(50) sam.backward(5)
sam.left(120) sam.left(90)
sam.forward(50) sam.forward(20)
loopCount=loopCount+1
window.mainloop()

For Loop and the Turtle


import turtle
# Create Window
window = turtle.Screen()
# Create Turtle
sam = turtle.Turtle()
# Loop Turtle
for i in range(0,11):
sam.left(30)
sam.forward(50)
sam.left(120)
sam.forward(50)
window.mainloop()

3
4/12/2024

Turtle.pdf

Follow the instructions in the tutorial Turtle.pdf

Turtle Examples

Follow the instructions in the tutorial TurtleExamples.pdf

You might also like