SlideShare une entreprise Scribd logo
1  sur  4
Using a Turtle
Imagine a Turtle …
 Crawling over a huge
sheet of paper
 With a pen tied to its
tail.




You can command it.
The basics

Tells Python to use the
Turtle module

Sets up a Turtle and makes
it a Turtle Shape

Moves forward 100 pixels
Turns right by 90 degrees

Closes the graphic window
when you quit
Challenges


Draw a square:
 By repeating the same commands four times


 Using ‘For I in range(4):’ 



Draw a hexagon
Allow the user to say how many sides
the polygon should have
 Remember, use

‘myVariable = int(raw_input)’ to get a
number from the user


Get the turtle to draw your initials

Contenu connexe

Tendances

Tendances (20)

Modules and packages in python
Modules and packages in pythonModules and packages in python
Modules and packages in python
 
Android intents
Android intentsAndroid intents
Android intents
 
Introduction to pandas
Introduction to pandasIntroduction to pandas
Introduction to pandas
 
Data types in python
Data types in pythonData types in python
Data types in python
 
Introduction to NumPy (PyData SV 2013)
Introduction to NumPy (PyData SV 2013)Introduction to NumPy (PyData SV 2013)
Introduction to NumPy (PyData SV 2013)
 
Functions and modules in python
Functions and modules in pythonFunctions and modules in python
Functions and modules in python
 
Python basics
Python basicsPython basics
Python basics
 
Lesson 03 python statement, indentation and comments
Lesson 03   python statement, indentation and commentsLesson 03   python statement, indentation and comments
Lesson 03 python statement, indentation and comments
 
Python : Data Types
Python : Data TypesPython : Data Types
Python : Data Types
 
Java input
Java inputJava input
Java input
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
Java awt
Java awtJava awt
Java awt
 
Python for Beginners(v1)
Python for Beginners(v1)Python for Beginners(v1)
Python for Beginners(v1)
 
OOP Assignment 03.pdf
OOP Assignment 03.pdfOOP Assignment 03.pdf
OOP Assignment 03.pdf
 
Python Programming Essentials - M6 - Code Blocks and Indentation
Python Programming Essentials - M6 - Code Blocks and IndentationPython Programming Essentials - M6 - Code Blocks and Indentation
Python Programming Essentials - M6 - Code Blocks and Indentation
 
Html links
Html linksHtml links
Html links
 
Python ppt
Python pptPython ppt
Python ppt
 
Android - Android Intent Types
Android - Android Intent TypesAndroid - Android Intent Types
Android - Android Intent Types
 
Introduction to CSS3
Introduction to CSS3Introduction to CSS3
Introduction to CSS3
 
Pandas
PandasPandas
Pandas
 

Plus de grahamwell (20)

Pseudocode
PseudocodePseudocode
Pseudocode
 
Excel =if function
Excel =if functionExcel =if function
Excel =if function
 
Excel Min max-average
Excel Min max-average Excel Min max-average
Excel Min max-average
 
What is binary and why do we use it?
What is binary and why do we use it?What is binary and why do we use it?
What is binary and why do we use it?
 
Introduction to touch develop
Introduction to touch developIntroduction to touch develop
Introduction to touch develop
 
Introduction to touch develop
Introduction to touch developIntroduction to touch develop
Introduction to touch develop
 
The software story
The software storyThe software story
The software story
 
Database field types
Database field typesDatabase field types
Database field types
 
Databases 101
Databases 101Databases 101
Databases 101
 
Kodu controls
Kodu controlsKodu controls
Kodu controls
 
Pascal names and types
Pascal names and typesPascal names and types
Pascal names and types
 
Python part two names and types
Python part two names and typesPython part two names and types
Python part two names and types
 
Abstraction - Year 9
Abstraction - Year 9Abstraction - Year 9
Abstraction - Year 9
 
Thinking about your project
Thinking about your projectThinking about your project
Thinking about your project
 
The rail fence
The rail fenceThe rail fence
The rail fence
 
Lesson 1
Lesson 1Lesson 1
Lesson 1
 
Rsa encryption
Rsa encryptionRsa encryption
Rsa encryption
 
Server side scripts
Server side scriptsServer side scripts
Server side scripts
 
Revision topic 1 sensors and control
Revision topic 1 sensors and controlRevision topic 1 sensors and control
Revision topic 1 sensors and control
 
Mtslesson
MtslessonMtslesson
Mtslesson
 

Turtle graphics

  • 1.
  • 2. Using a Turtle Imagine a Turtle …  Crawling over a huge sheet of paper  With a pen tied to its tail.   You can command it.
  • 3. The basics Tells Python to use the Turtle module Sets up a Turtle and makes it a Turtle Shape Moves forward 100 pixels Turns right by 90 degrees Closes the graphic window when you quit
  • 4. Challenges  Draw a square:  By repeating the same commands four times   Using ‘For I in range(4):’    Draw a hexagon Allow the user to say how many sides the polygon should have  Remember, use ‘myVariable = int(raw_input)’ to get a number from the user  Get the turtle to draw your initials