In this post we will be creating a Python script to draw a smiley face using the turtle library. The turtle library enables us to a virtual canvas where one can draw an endless number of shapes and pictures. It is especially useful for beginners, children and programmers wanting to have some fun – The library is limited only by imagination.
See the snippet of Python code below where we use the Python turtle library to draw a smiley face. If you find this useful be sure to check out some of our other Turtle examples here.
import turtle # Create turtle object smiley = turtle.Turtle() # Draw the head smiley.circle(100) # Draw the eyes smiley.penup() smiley.goto(-30, 110) smiley.pendown() smiley.circle(10) smiley.penup() smiley.goto(30, 110) smiley.pendown() smiley.circle(10) # Draw the mouth smiley.penup() smiley.goto(-40, 85) smiley.down() smiley.right(90) smiley.circle(40, 180) smiley.up() # Hide the turtle smiley.hideturtle() # Wait for user to close the window turtle.done()
The above would output the following to a canvas and leave it open.
If you do create your own, please do share with us as we would love to see! Also be sure to check out some of our other Turtle examples here.
Take a look at some of our other content around the Python programming language by clicking here.