How to Draw a Heart Shape with Python's Turtle Module

Today's article will teach you how to draw a heart shape using the Python Turtle module. This lesson will mostly target beginner and intermediate Python coders.

I've included the Python turtle code for making a heart shape below. Simply copy, paste, and run the code in a Python compiler.

Source Code :

import turtle

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

# Move the turtle to the starting position
t.penup()
t.goto(0, 0)
t.pendown()

# Set the fill color to red
t.fillcolor("red")

# Draw the heart shape
t.begin_fill()
t.left(45)
t.forward(100)
t.circle(50, 180)
t.right(90)
t.circle(50, 180)
t.forward(100)
t.end_fill()

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

Output :


hope you found this lesson useful, and if so, please share it with your fellow programmers.

Post a Comment

Previous Post Next Post