WORKING WITH GRAPHICS
By Zeeshan Hussain (Software Engineer)
Portfolio: Universedeveloper.netlify.app | WhatsApp: +923181482800 | Lecturer: Zeeshan Hussain
INTRODUCTION TO TURTLE
• Turtle is a pre-installed Python library that enables users to create
pictures and shapes by providing them with a virtual canvas.
• The onscreen pen that you use for drawing is called the turtle and this
is what gives the library its name.
• It’s used to developed thinking skill in children and also used to teach
programing concept through drawing.
Portfolio: Universedeveloper.netlify.app | WhatsApp: +923181482800 | Lecturer: Zeeshan Hussain
HOW TO USE TURTLE ?
• Using the Turtle module in Python involves a few basic steps to create
drawings or animations.
• Here's a simple guide on how to use Turtle:
• Import the Turtle module: Start by importing the turtle module.
Portfolio: Universedeveloper.netlify.app | WhatsApp: +923181482800 | Lecturer: Zeeshan Hussain
BASIC TURTLE COMMANDS
• Here are some of the basic commands you can use with the Turtle
module in Python:
• bgColor(): # Set the background color.
• showTurtle(): # Show the turtle.
• hideTrutle(): # Hide the turtle.
• Color(): # Set the color of the turtle's pen.
• done(): # Keep the window open.
Portfolio: Universedeveloper.netlify.app | WhatsApp: +923181482800 | Lecturer: Zeeshan Hussain
MOVING THE TURTLE
• There are four directions that a turtle can move in:
• Forward()
• Backward()
• Left()
• Right()
• The turtle moves .forward() or .backward() in the direction that it’s
facing.
• You can change this direction by turning it .left() or .right() by a
certain degree.
Portfolio: Universedeveloper.netlify.app | WhatsApp: +923181482800 | Lecturer: Zeeshan Hussain
DRAWING LINES
• To draw lines using the Turtle module in Python, you can use the
forward() method to move the turtle forward and backward() method
to move it backward.
• Example:
Portfolio: Universedeveloper.netlify.app | WhatsApp: +923181482800 | Lecturer: Zeeshan Hussain
DRAWING SQUARE
• To draw a square using the Turtle module in Python, you can use a
loop to repeat the movement and rotation commands four times.
• Example:
Portfolio: Universedeveloper.netlify.app | WhatsApp: +923181482800 | Lecturer: Zeeshan Hussain
DRAWING RECTANGLE
• To draw a rectangle using the Turtle module in Python, you can adjust
the distances moved and angles turned to create a shape with two
pairs of parallel sides.
• Example:
Portfolio: Universedeveloper.netlify.app | WhatsApp: +923181482800 | Lecturer: Zeeshan Hussain
DRAWING CIRCLE
• To draw a circle using the Turtle module in Python, you can use the
circle() method or manually you can achieve it by drawing multiple
straight lines to approximate the shape of a circle.
• Example:
Portfolio: Universedeveloper.netlify.app | WhatsApp: +923181482800 | Lecturer: Zeeshan Hussain
DRAWING STAR
• To draw a star using the Turtle module in Python, you can use a loop
to create the arms of the star by moving and turning the turtle
appropriately.
• Example:
Portfolio: Universedeveloper.netlify.app | WhatsApp: +923181482800 | Lecturer: Zeeshan Hussain
IF ANY QUESTION, YOU CAN
ASK!
Portfolio: Universedeveloper.netlify.app | WhatsApp: +923181482800 | Lecturer: Zeeshan Hussain
THANK YOU!
Portfolio: Universedeveloper.netlify.app | WhatsApp: +923181482800 | Lecturer: Zeeshan Hussain