SlideShare una empresa de Scribd logo
1 de 25
An Introduction To Software
Development Using Python
Spring Semester, 2015
Class #4.5:
Graphics
How To Do Graphics In Python?
You
Tkinter / Ttk
Tkinter is Python's
de-facto standard
GUI (Graphical User
Interface) package.
Turtle
PythonTurtle strives to provide
the lowest-threshold way to
learn (or teach) software
development in the Python
programming language.
What Is Turtle Graphics?
• Logo is an educational programming
language, designed in 1967 by Daniel G.
Bobrow, Wally Feurzeig, Seymour Papert
and Cynthia Solomon.
• Today the language is remembered
mainly for its use of "turtle graphics", in
which commands for movement and
drawing produced line graphics either on
screen or with a small robot called a
"turtle".
Image Credit: el.media.mit.edu
What Is Turtle In Python?
• Imagine a robotic turtle starting at (0, 0)
in the x-y plane.
• Execute the import turtle Python
command
• Now give it the command
turtle.forward(15), and it moves (on-
screen!) 15 pixels in the direction it is
facing, drawing a line as it moves.
• Give it the command turtle.right(25), and
it rotates in-place 25 degrees clockwise.
Image Credit: www.turtlemob.com
Tic-Tac-Toe: What It Is
X
O
Turtle Motion
• turtle.forward(distance)
• turtle.back(distance)
• turtle.right(angle)
• turtle.left(angle)
• turtle.goto(x, y=None)
• turtle.setx(x)
• turtle.sety(y)
• turtle.home()
Image Creditmegaicons.net
Turtle Heading
• turtle.setheading(to_angle)
Turtle Pen Control
• turtle.pendown()
• turtle.penup()
• turtle.pensize(width=None)
Image www.clipartpanda.com
Turtle Color Control
• turtle.pencolor(*args)
• turtle.fillcolor(*args)
Image www.clipartlord.com
Tic-Tac-Toe: What It Is
(0,0)
(-200,+200) (+200,+200)
(+200,-200)(-200,-200)
(-100,+200) (+100,+200)
(-100,-200) (+100,-200)
(-200,-75)
(-200,+75)
(+200,-75)
(+200,+75)
Drawing The First Vertical Line
#
# Python program to use the Turtle library to draw a Tic-Tac-Toe board
#
# Spring Semester, 2015
#
#
# Get Turtle library
import turtle
# Configure Turtle to draw thick red lines
turtle.pensize(10)
turtle.color("red")
# Lift the pen and move to the top of the left vertical line
turtle.penup()
turtle.goto(-110, 200)
# Put the pen down, point South, and move to bottom of Tic-Tac-Toe grid
turtle.pendown()
turtle.setheading(270)
turtle.forward(400)
(-100,+200)
(-100,-200)
Drawing The Second Vertical Line
# Draw the second vertical line
#
# Lift the pen up and move to the top of the second vertical line
turtle.penup()
turtle.goto(100, 200)
# Put the pen down, point South, and move to bottom of Tic-Tac-Toe grid
turtle.pendown()
turtle.setheading(270)
turtle.forward(400)
(+100,+200)
(+100,-200)
Draw The Top Horizontal Line
# Draw the top horizontal line
#
# Lift the pen up and move to the leftmost start of the top horizontal line
turtle.penup()
turtle.goto(-200,100)
# Put the pen down, point East, and move to right hand side of Tic-Tac-Toe grid
turtle.pendown()
turtle.setheading(0)
turtle.forward(400)
(-200,+75) (+200,+75)
Draw The Bottom Horizontal Line
# Draw the bottom horizontal line
#
# Lift the pen up and move to the leftmost start of the bottom horizontal line
turtle.penup()
turtle.goto(-200,-100)
# Put the pen down, point East, and move to right hand side of Tic-Tac-Toe grid
turtle.pendown()
turtle.setheading(0)
turtle.forward(400)
(-200,-75) (+200,-75)
Turtle Circles
• turtle.circle(radius, extent=None, steps=None)
• Draw a circle with given radius. The center is radius units left of the turtle; extent –
an angle – determines which part of the circle is drawn. If extent is not given, draw
the entire circle. If extent is not a full circle, one endpoint of the arc is the current
pen position. Draw the arc in counterclockwise direction if radius is positive,
otherwise in clockwise direction. Finally the direction of the turtle is changed by
the amount of extent.
• As the circle is approximated by an inscribed regular polygon, steps determines the
number of steps to use.
Adding An “O” To Tic-Tac-Toe
The “O” goes here!
“O” Code
# Add an "O" to the tic-tac-toe grid
#
# Lift pen, move to center, put pen down, draw a circle
turtle.penup()
turtle.goto(0,-50)
turtle.pendown()
turtle.circle(50)
Adding An “X” To Tic-Tac-Toe
The “X” goes here!
“X” Code
# Add an "X" to the tic-tac-toe grid
#
# Lift pen, move to bottom left of upper left square
turtle.penup()
turtle.goto(-180,95)
turtle.pendown()
# Point pen in north east direction and draw a line
turtle.setheading(45)
turtle.goto(-120,180)
# Lift pen, move to upper left of upper left square
turtle.penup()
turtle.goto(-180,180)
turtle.pendown()
# Point pen in north east direction and draw a line
turtle.setheading(315)
turtle.goto(-120,95)
Turtle Extras
• turtle.dot(size=None, *color)
• turtle.stamp()
• turtle.clearstamp(stampid)
• turtle.clearstamps(n=None)
• turtle.undo()
• turtle.speed(speed=None)
– If input is a number greater than 10 or smaller than 0.5, speed is set to 0. Speedstrings
are mapped to speedvalues as follows:
• “fastest”: 0
• “fast”: 10
• “normal”: 6
• “slow”: 3
• “slowest”: 1
Turtle Stamp
Image www.webweaver.nu
Turtle State
• turtle.position()
• turtle.towards(x, y=None)
• turtle.xcor()
• turtle.ycor()
• turtle.heading()
• turtle.distance(x, y=None)
Image www.clipartbest.com
Turtle Pen Control
• turtle.pendown()
• turtle.penup()
• turtle.pensize(width=None)
• turtle.isdown()
Image 4vector.com
Turtle Filling
• turtle.begin_fill()
• turtle.end_fill()
Image www.dreamstime.com
What We Covered Today
1. Turtle graphics
2. Drawing lines
3. Drawing circles
4. Filling shapes
Image Credit: http://www.tswdj.com/blog/2011/05/17/the-grooms-checklist/
What We’ll Be Covering Next Time
1. IF Statement
2. Relational Operators
Image Credit: http://merchantblog.thefind.com/2011/01/merchant-newsletter/resolve-to-take-advantage-of-these-5-e-commerce-trends/attachment/crystal-ball-fullsize/

Más contenido relacionado

La actualidad más candente

Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02Fariz Darari
 
Html text and formatting
Html text and formattingHtml text and formatting
Html text and formattingeShikshak
 
Introduction to Basics of Python
Introduction to Basics of PythonIntroduction to Basics of Python
Introduction to Basics of PythonElewayte
 
Introduction to NumPy
Introduction to NumPyIntroduction to NumPy
Introduction to NumPyHuy Nguyen
 
What is Dictionary In Python? Python Dictionary Tutorial | Edureka
What is Dictionary In Python? Python Dictionary Tutorial | EdurekaWhat is Dictionary In Python? Python Dictionary Tutorial | Edureka
What is Dictionary In Python? Python Dictionary Tutorial | EdurekaEdureka!
 
Datastructures in python
Datastructures in pythonDatastructures in python
Datastructures in pythonhydpy
 
Intro to Python for Non-Programmers
Intro to Python for Non-ProgrammersIntro to Python for Non-Programmers
Intro to Python for Non-ProgrammersAhmad Alhour
 
Ketoprak_PPT ADT Stack dan Queue.pptx
Ketoprak_PPT ADT Stack dan Queue.pptxKetoprak_PPT ADT Stack dan Queue.pptx
Ketoprak_PPT ADT Stack dan Queue.pptxputii1
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to PythonNowell Strite
 
Python Dictionaries and Sets
Python Dictionaries and SetsPython Dictionaries and Sets
Python Dictionaries and SetsNicole Ryan
 
Python 101: Python for Absolute Beginners (PyTexas 2014)
Python 101: Python for Absolute Beginners (PyTexas 2014)Python 101: Python for Absolute Beginners (PyTexas 2014)
Python 101: Python for Absolute Beginners (PyTexas 2014)Paige Bailey
 

La actualidad más candente (20)

Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02
 
Python programming : List and tuples
Python programming : List and tuplesPython programming : List and tuples
Python programming : List and tuples
 
Html text and formatting
Html text and formattingHtml text and formatting
Html text and formatting
 
Python: Basic Inheritance
Python: Basic InheritancePython: Basic Inheritance
Python: Basic Inheritance
 
Python programming : Strings
Python programming : StringsPython programming : Strings
Python programming : Strings
 
Introduction to Basics of Python
Introduction to Basics of PythonIntroduction to Basics of Python
Introduction to Basics of Python
 
Python Basics
Python BasicsPython Basics
Python Basics
 
Python
PythonPython
Python
 
Css pseudo-classes
Css pseudo-classesCss pseudo-classes
Css pseudo-classes
 
Introduction to NumPy
Introduction to NumPyIntroduction to NumPy
Introduction to NumPy
 
What is Dictionary In Python? Python Dictionary Tutorial | Edureka
What is Dictionary In Python? Python Dictionary Tutorial | EdurekaWhat is Dictionary In Python? Python Dictionary Tutorial | Edureka
What is Dictionary In Python? Python Dictionary Tutorial | Edureka
 
Python
PythonPython
Python
 
Datastructures in python
Datastructures in pythonDatastructures in python
Datastructures in python
 
Intro to Python for Non-Programmers
Intro to Python for Non-ProgrammersIntro to Python for Non-Programmers
Intro to Python for Non-Programmers
 
Ketoprak_PPT ADT Stack dan Queue.pptx
Ketoprak_PPT ADT Stack dan Queue.pptxKetoprak_PPT ADT Stack dan Queue.pptx
Ketoprak_PPT ADT Stack dan Queue.pptx
 
HTML Forms
HTML FormsHTML Forms
HTML Forms
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
Python Dictionaries and Sets
Python Dictionaries and SetsPython Dictionaries and Sets
Python Dictionaries and Sets
 
Python 101: Python for Absolute Beginners (PyTexas 2014)
Python 101: Python for Absolute Beginners (PyTexas 2014)Python 101: Python for Absolute Beginners (PyTexas 2014)
Python 101: Python for Absolute Beginners (PyTexas 2014)
 
Python programming
Python  programmingPython  programming
Python programming
 

Destacado

An Introduction To Python - Python Midterm Review
An Introduction To Python - Python Midterm ReviewAn Introduction To Python - Python Midterm Review
An Introduction To Python - Python Midterm ReviewBlue Elephant Consulting
 
An Introduction To Python - Working With Data
An Introduction To Python - Working With DataAn Introduction To Python - Working With Data
An Introduction To Python - Working With DataBlue Elephant Consulting
 
An Introduction To Python - Functions, Part 2
An Introduction To Python - Functions, Part 2An Introduction To Python - Functions, Part 2
An Introduction To Python - Functions, Part 2Blue Elephant Consulting
 
An Introduction To Software Development - Software Support and Maintenance
An Introduction To Software Development - Software Support and MaintenanceAn Introduction To Software Development - Software Support and Maintenance
An Introduction To Software Development - Software Support and MaintenanceBlue Elephant Consulting
 
An Introduction To Python - Variables, Math
An Introduction To Python - Variables, MathAn Introduction To Python - Variables, Math
An Introduction To Python - Variables, MathBlue Elephant Consulting
 
An Introduction To Python - Python, Print()
An Introduction To Python - Python, Print()An Introduction To Python - Python, Print()
An Introduction To Python - Python, Print()Blue Elephant Consulting
 
An Introduction To Software Development - Implementation
An Introduction To Software Development - ImplementationAn Introduction To Software Development - Implementation
An Introduction To Software Development - ImplementationBlue Elephant Consulting
 
An Introduction To Python - Nested Branches, Multiple Alternatives
An Introduction To Python - Nested Branches, Multiple AlternativesAn Introduction To Python - Nested Branches, Multiple Alternatives
An Introduction To Python - Nested Branches, Multiple AlternativesBlue Elephant Consulting
 
An Introduction To Software Development - Architecture & Detailed Design
An Introduction To Software Development - Architecture & Detailed DesignAn Introduction To Software Development - Architecture & Detailed Design
An Introduction To Software Development - Architecture & Detailed DesignBlue Elephant Consulting
 
An Introduction To Python - Tables, List Algorithms
An Introduction To Python - Tables, List AlgorithmsAn Introduction To Python - Tables, List Algorithms
An Introduction To Python - Tables, List AlgorithmsBlue Elephant Consulting
 

Destacado (16)

An Introduction To Python - Python Midterm Review
An Introduction To Python - Python Midterm ReviewAn Introduction To Python - Python Midterm Review
An Introduction To Python - Python Midterm Review
 
An Introduction To Python - Working With Data
An Introduction To Python - Working With DataAn Introduction To Python - Working With Data
An Introduction To Python - Working With Data
 
An Introduction To Python - Functions, Part 2
An Introduction To Python - Functions, Part 2An Introduction To Python - Functions, Part 2
An Introduction To Python - Functions, Part 2
 
An Introduction To Software Development - Software Support and Maintenance
An Introduction To Software Development - Software Support and MaintenanceAn Introduction To Software Development - Software Support and Maintenance
An Introduction To Software Development - Software Support and Maintenance
 
An Introduction To Python - FOR Loop
An Introduction To Python - FOR LoopAn Introduction To Python - FOR Loop
An Introduction To Python - FOR Loop
 
An Introduction To Python - Variables, Math
An Introduction To Python - Variables, MathAn Introduction To Python - Variables, Math
An Introduction To Python - Variables, Math
 
An Introduction To Python - Python, Print()
An Introduction To Python - Python, Print()An Introduction To Python - Python, Print()
An Introduction To Python - Python, Print()
 
An Introduction To Python - WHILE Loop
An Introduction To  Python - WHILE LoopAn Introduction To  Python - WHILE Loop
An Introduction To Python - WHILE Loop
 
An Introduction To Python - Lists, Part 1
An Introduction To Python - Lists, Part 1An Introduction To Python - Lists, Part 1
An Introduction To Python - Lists, Part 1
 
An Introduction To Software Development - Implementation
An Introduction To Software Development - ImplementationAn Introduction To Software Development - Implementation
An Introduction To Software Development - Implementation
 
An Introduction To Python - Nested Branches, Multiple Alternatives
An Introduction To Python - Nested Branches, Multiple AlternativesAn Introduction To Python - Nested Branches, Multiple Alternatives
An Introduction To Python - Nested Branches, Multiple Alternatives
 
An Introduction To Python - Lists, Part 2
An Introduction To Python - Lists, Part 2An Introduction To Python - Lists, Part 2
An Introduction To Python - Lists, Part 2
 
An Introduction To Software Development - Architecture & Detailed Design
An Introduction To Software Development - Architecture & Detailed DesignAn Introduction To Software Development - Architecture & Detailed Design
An Introduction To Software Development - Architecture & Detailed Design
 
An Introduction To Python - Files, Part 1
An Introduction To Python - Files, Part 1An Introduction To Python - Files, Part 1
An Introduction To Python - Files, Part 1
 
An Introduction To Python - Dictionaries
An Introduction To Python - DictionariesAn Introduction To Python - Dictionaries
An Introduction To Python - Dictionaries
 
An Introduction To Python - Tables, List Algorithms
An Introduction To Python - Tables, List AlgorithmsAn Introduction To Python - Tables, List Algorithms
An Introduction To Python - Tables, List Algorithms
 

Similar a An Introduction To Python - Graphics

Kojo - CASE April 2010
Kojo - CASE April 2010Kojo - CASE April 2010
Kojo - CASE April 2010mtye
 
Introduction to the basic mathematical concept with Python Turtle.
Introduction to the basic mathematical concept with Python Turtle.Introduction to the basic mathematical concept with Python Turtle.
Introduction to the basic mathematical concept with Python Turtle.NR Computer Learning Center
 
Intro to Python (High School) Unit #3
Intro to Python (High School) Unit #3Intro to Python (High School) Unit #3
Intro to Python (High School) Unit #3Jay Coskey
 
014 TUPLES.pdf
014 TUPLES.pdf014 TUPLES.pdf
014 TUPLES.pdfamman23
 
pyconjp2015_talk_Translation of Python Program__
pyconjp2015_talk_Translation of Python Program__pyconjp2015_talk_Translation of Python Program__
pyconjp2015_talk_Translation of Python Program__Renyuan Lyu
 
Ry pyconjp2015 turtle
Ry pyconjp2015 turtleRy pyconjp2015 turtle
Ry pyconjp2015 turtleRenyuan Lyu
 
Go Containers
Go ContainersGo Containers
Go Containersjgrahamc
 
Introduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdfIntroduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdfsumitt6_25730773
 
Python for High School Programmers
Python for High School ProgrammersPython for High School Programmers
Python for High School ProgrammersSiva Arunachalam
 
Artificial intelligence - python
Artificial intelligence - pythonArtificial intelligence - python
Artificial intelligence - pythonSunjid Hasan
 
Creative Coding 1 - 1 Introduction
Creative Coding 1 - 1 IntroductionCreative Coding 1 - 1 Introduction
Creative Coding 1 - 1 IntroductionTill Nagel
 

Similar a An Introduction To Python - Graphics (16)

Kojo - CASE April 2010
Kojo - CASE April 2010Kojo - CASE April 2010
Kojo - CASE April 2010
 
Introduction to the basic mathematical concept with Python Turtle.
Introduction to the basic mathematical concept with Python Turtle.Introduction to the basic mathematical concept with Python Turtle.
Introduction to the basic mathematical concept with Python Turtle.
 
Python book
Python bookPython book
Python book
 
Intro to Python (High School) Unit #3
Intro to Python (High School) Unit #3Intro to Python (High School) Unit #3
Intro to Python (High School) Unit #3
 
Pa1 turtle
Pa1 turtlePa1 turtle
Pa1 turtle
 
014 TUPLES.pdf
014 TUPLES.pdf014 TUPLES.pdf
014 TUPLES.pdf
 
pyconjp2015_talk_Translation of Python Program__
pyconjp2015_talk_Translation of Python Program__pyconjp2015_talk_Translation of Python Program__
pyconjp2015_talk_Translation of Python Program__
 
Baabtra.com little coder chapter - 4
Baabtra.com little coder   chapter - 4Baabtra.com little coder   chapter - 4
Baabtra.com little coder chapter - 4
 
Ry pyconjp2015 turtle
Ry pyconjp2015 turtleRy pyconjp2015 turtle
Ry pyconjp2015 turtle
 
Go Containers
Go ContainersGo Containers
Go Containers
 
Go Containers
Go ContainersGo Containers
Go Containers
 
Introduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdfIntroduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdf
 
Python for High School Programmers
Python for High School ProgrammersPython for High School Programmers
Python for High School Programmers
 
Artificial intelligence - python
Artificial intelligence - pythonArtificial intelligence - python
Artificial intelligence - python
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Creative Coding 1 - 1 Introduction
Creative Coding 1 - 1 IntroductionCreative Coding 1 - 1 Introduction
Creative Coding 1 - 1 Introduction
 

Último

The Ultimate Guide to Social Media Marketing in 2024.pdf
The Ultimate Guide to Social Media Marketing in 2024.pdfThe Ultimate Guide to Social Media Marketing in 2024.pdf
The Ultimate Guide to Social Media Marketing in 2024.pdfdm4ashexcelr
 
Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17Celine George
 
[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online PresentationGDSCYCCE
 
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & EngineeringBasic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & EngineeringDenish Jangid
 
factors influencing drug absorption-final-2.pptx
factors influencing drug absorption-final-2.pptxfactors influencing drug absorption-final-2.pptx
factors influencing drug absorption-final-2.pptxSanjay Shekar
 
Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024CapitolTechU
 
IATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdffIATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdff17thcssbs2
 
MichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdfMichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdfmstarkes24
 
Telling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdf
Telling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdfTelling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdf
Telling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdfTechSoup
 
....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdfVikramadityaRaj
 
Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Mohamed Rizk Khodair
 
Essential Safety precautions during monsoon season
Essential Safety precautions during monsoon seasonEssential Safety precautions during monsoon season
Essential Safety precautions during monsoon seasonMayur Khatri
 
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...Nguyen Thanh Tu Collection
 
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45MysoreMuleSoftMeetup
 
Behavioral-sciences-dr-mowadat rana (1).pdf
Behavioral-sciences-dr-mowadat rana (1).pdfBehavioral-sciences-dr-mowadat rana (1).pdf
Behavioral-sciences-dr-mowadat rana (1).pdfaedhbteg
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfbu07226
 
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General QuizPragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General QuizPragya - UEM Kolkata Quiz Club
 
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17Celine George
 

Último (20)

The Ultimate Guide to Social Media Marketing in 2024.pdf
The Ultimate Guide to Social Media Marketing in 2024.pdfThe Ultimate Guide to Social Media Marketing in 2024.pdf
The Ultimate Guide to Social Media Marketing in 2024.pdf
 
Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17
 
[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation
 
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & EngineeringBasic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
 
factors influencing drug absorption-final-2.pptx
factors influencing drug absorption-final-2.pptxfactors influencing drug absorption-final-2.pptx
factors influencing drug absorption-final-2.pptx
 
Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024Capitol Tech Univ Doctoral Presentation -May 2024
Capitol Tech Univ Doctoral Presentation -May 2024
 
IATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdffIATP How-to Foreign Travel May 2024.pdff
IATP How-to Foreign Travel May 2024.pdff
 
MichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdfMichaelStarkes_UncutGemsProjectSummary.pdf
MichaelStarkes_UncutGemsProjectSummary.pdf
 
Telling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdf
Telling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdfTelling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdf
Telling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdf
 
....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf
 
Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).
 
Essential Safety precautions during monsoon season
Essential Safety precautions during monsoon seasonEssential Safety precautions during monsoon season
Essential Safety precautions during monsoon season
 
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
 
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
 
Behavioral-sciences-dr-mowadat rana (1).pdf
Behavioral-sciences-dr-mowadat rana (1).pdfBehavioral-sciences-dr-mowadat rana (1).pdf
Behavioral-sciences-dr-mowadat rana (1).pdf
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
 
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General QuizPragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
Pragya Champions Chalice 2024 Prelims & Finals Q/A set, General Quiz
 
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdf
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdfPost Exam Fun(da) Intra UEM General Quiz - Finals.pdf
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdf
 
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
 
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
Operations Management - Book1.p  - Dr. Abdulfatah A. SalemOperations Management - Book1.p  - Dr. Abdulfatah A. Salem
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
 

An Introduction To Python - Graphics

  • 1. An Introduction To Software Development Using Python Spring Semester, 2015 Class #4.5: Graphics
  • 2. How To Do Graphics In Python? You Tkinter / Ttk Tkinter is Python's de-facto standard GUI (Graphical User Interface) package. Turtle PythonTurtle strives to provide the lowest-threshold way to learn (or teach) software development in the Python programming language.
  • 3. What Is Turtle Graphics? • Logo is an educational programming language, designed in 1967 by Daniel G. Bobrow, Wally Feurzeig, Seymour Papert and Cynthia Solomon. • Today the language is remembered mainly for its use of "turtle graphics", in which commands for movement and drawing produced line graphics either on screen or with a small robot called a "turtle". Image Credit: el.media.mit.edu
  • 4. What Is Turtle In Python? • Imagine a robotic turtle starting at (0, 0) in the x-y plane. • Execute the import turtle Python command • Now give it the command turtle.forward(15), and it moves (on- screen!) 15 pixels in the direction it is facing, drawing a line as it moves. • Give it the command turtle.right(25), and it rotates in-place 25 degrees clockwise. Image Credit: www.turtlemob.com
  • 6. Turtle Motion • turtle.forward(distance) • turtle.back(distance) • turtle.right(angle) • turtle.left(angle) • turtle.goto(x, y=None) • turtle.setx(x) • turtle.sety(y) • turtle.home() Image Creditmegaicons.net
  • 8. Turtle Pen Control • turtle.pendown() • turtle.penup() • turtle.pensize(width=None) Image www.clipartpanda.com
  • 9. Turtle Color Control • turtle.pencolor(*args) • turtle.fillcolor(*args) Image www.clipartlord.com
  • 10. Tic-Tac-Toe: What It Is (0,0) (-200,+200) (+200,+200) (+200,-200)(-200,-200) (-100,+200) (+100,+200) (-100,-200) (+100,-200) (-200,-75) (-200,+75) (+200,-75) (+200,+75)
  • 11. Drawing The First Vertical Line # # Python program to use the Turtle library to draw a Tic-Tac-Toe board # # Spring Semester, 2015 # # # Get Turtle library import turtle # Configure Turtle to draw thick red lines turtle.pensize(10) turtle.color("red") # Lift the pen and move to the top of the left vertical line turtle.penup() turtle.goto(-110, 200) # Put the pen down, point South, and move to bottom of Tic-Tac-Toe grid turtle.pendown() turtle.setheading(270) turtle.forward(400) (-100,+200) (-100,-200)
  • 12. Drawing The Second Vertical Line # Draw the second vertical line # # Lift the pen up and move to the top of the second vertical line turtle.penup() turtle.goto(100, 200) # Put the pen down, point South, and move to bottom of Tic-Tac-Toe grid turtle.pendown() turtle.setheading(270) turtle.forward(400) (+100,+200) (+100,-200)
  • 13. Draw The Top Horizontal Line # Draw the top horizontal line # # Lift the pen up and move to the leftmost start of the top horizontal line turtle.penup() turtle.goto(-200,100) # Put the pen down, point East, and move to right hand side of Tic-Tac-Toe grid turtle.pendown() turtle.setheading(0) turtle.forward(400) (-200,+75) (+200,+75)
  • 14. Draw The Bottom Horizontal Line # Draw the bottom horizontal line # # Lift the pen up and move to the leftmost start of the bottom horizontal line turtle.penup() turtle.goto(-200,-100) # Put the pen down, point East, and move to right hand side of Tic-Tac-Toe grid turtle.pendown() turtle.setheading(0) turtle.forward(400) (-200,-75) (+200,-75)
  • 15. Turtle Circles • turtle.circle(radius, extent=None, steps=None) • Draw a circle with given radius. The center is radius units left of the turtle; extent – an angle – determines which part of the circle is drawn. If extent is not given, draw the entire circle. If extent is not a full circle, one endpoint of the arc is the current pen position. Draw the arc in counterclockwise direction if radius is positive, otherwise in clockwise direction. Finally the direction of the turtle is changed by the amount of extent. • As the circle is approximated by an inscribed regular polygon, steps determines the number of steps to use.
  • 16. Adding An “O” To Tic-Tac-Toe The “O” goes here!
  • 17. “O” Code # Add an "O" to the tic-tac-toe grid # # Lift pen, move to center, put pen down, draw a circle turtle.penup() turtle.goto(0,-50) turtle.pendown() turtle.circle(50)
  • 18. Adding An “X” To Tic-Tac-Toe The “X” goes here!
  • 19. “X” Code # Add an "X" to the tic-tac-toe grid # # Lift pen, move to bottom left of upper left square turtle.penup() turtle.goto(-180,95) turtle.pendown() # Point pen in north east direction and draw a line turtle.setheading(45) turtle.goto(-120,180) # Lift pen, move to upper left of upper left square turtle.penup() turtle.goto(-180,180) turtle.pendown() # Point pen in north east direction and draw a line turtle.setheading(315) turtle.goto(-120,95)
  • 20. Turtle Extras • turtle.dot(size=None, *color) • turtle.stamp() • turtle.clearstamp(stampid) • turtle.clearstamps(n=None) • turtle.undo() • turtle.speed(speed=None) – If input is a number greater than 10 or smaller than 0.5, speed is set to 0. Speedstrings are mapped to speedvalues as follows: • “fastest”: 0 • “fast”: 10 • “normal”: 6 • “slow”: 3 • “slowest”: 1 Turtle Stamp Image www.webweaver.nu
  • 21. Turtle State • turtle.position() • turtle.towards(x, y=None) • turtle.xcor() • turtle.ycor() • turtle.heading() • turtle.distance(x, y=None) Image www.clipartbest.com
  • 22. Turtle Pen Control • turtle.pendown() • turtle.penup() • turtle.pensize(width=None) • turtle.isdown() Image 4vector.com
  • 23. Turtle Filling • turtle.begin_fill() • turtle.end_fill() Image www.dreamstime.com
  • 24. What We Covered Today 1. Turtle graphics 2. Drawing lines 3. Drawing circles 4. Filling shapes Image Credit: http://www.tswdj.com/blog/2011/05/17/the-grooms-checklist/
  • 25. What We’ll Be Covering Next Time 1. IF Statement 2. Relational Operators Image Credit: http://merchantblog.thefind.com/2011/01/merchant-newsletter/resolve-to-take-advantage-of-these-5-e-commerce-trends/attachment/crystal-ball-fullsize/

Notas del editor

  1. New name for the class I know what this means Technical professionals are who get hired This means much more than just having a narrow vertical knowledge of some subject area. It means that you know how to produce an outcome that I value. I’m willing to pay you to do that.