0% found this document useful (0 votes)
16 views

Lab1 Numpymatplotlib

Uploaded by

ShivangiMatieda
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Lab1 Numpymatplotlib

Uploaded by

ShivangiMatieda
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Introduction to Turtle

module
Python Turtle Graphics
• Turtle graphics is a type of computer graphics that draws relative to
the position of a virtual turtle on the screen.
• The turtle holds a pen, and if the pen is down when the turtle moves,
then a line will be drawn. The turtle may
• also move with the pen up or initiate other types of drawing such as
drawing a dot.
Turtle module: basic functions
• forward(distance) forward(10)
• Move turtle forward distance units.
• backward(distance) or back(distance) back(50)
• Move turtle backwards distance units.
• left(angle) left(30)
• Turn turtle left angle degrees.
• right(angle)
• Turn turtle right angle degrees.
• setheading(angle)
• Rotate turtle to point in direction angle. 0 faces to the right.
Turtle module: basic functions
• exitonclick()
• Close turtle window when clicked.
• pendown()
• Set turtle to draw when it moves.
• penup()
• Set turtle to not draw when it moves.
• dot(size)
• Draw a dot at current location of optional size.
Importing Turtle module
• In order to use these Python turtle functions, they must be imported
from the turtle module first
• The Python Standard Library consists of many modules, each of
which adds a specific set of additional functionality to the basic
language.
• To import a library module, use an import statement:
• from module import * from turtle import *
The star at the end imports all available names from the given
module.

You might also like