Python Turtle – Draw the Dollar sign

In this post we will be creating a Python script to draw the dollar sign seen as ‘$’ 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 the dollar sign.

import turtle

# Create a turtle object
t = turtle.Turtle()

# Move the turtle to the starting point
t.penup()
t.goto(-100, 0)
t.pendown()

# Draw the S
t.forward(45)
t.circle(50, 180)
t.circle(-50, 180)
t.forward(45)

#Draw the first horizontal line
t.penup()
t.goto(-70, -10)
t.setheading(90)
t.pendown()
t.forward(225)

#Draw the second horizontal line
t.penup()
t.goto(-50, -10)
t.setheading(90)
t.pendown()
t.forward(225)

# Hide the turtle
t.hideturtle()

# Keep the window open until it is manually closed
turtle.done()

The above would output the following to a canvas and leave it open.

Python Turtle - Draw the Dollar sign

If you do create your own, please do share with us as we would love to see!

Take a look at some of our other content around the Python programming language by clicking here.

Leave a Reply