Draw Heart with Python using Turtle

Search for a command to run...

Thanks for sharing the knowledge Ayushi !! Always something new learning from you !!
Gald you liked it
The series content will mostly cover Technical Python tutorials and my recent learnings and experience in Python.
Hello Reader, hope you and your family is in good health! Javascript is a very powerful language, honestly, I am a baby in Js but I have always wondered, can Js integrated with Python. Recently, I was surfing the Internet and Js2Py module appeared i...
All you need to know about Hacktoberfest 2021

Hello reader! Well, Hacktoberfest is something, you are gonna hear a lot about in the coming month. You can refer to my YouTube video Tutorial to see a working tutorial for better understanding and a step-by-step guide of the same. https://www.yo...

Hello reader! In this Blog post, I will share some useful code snippets and functions in Python. Give it a read. Let's get started! 1. Memory The method getsizeof can be used to retrieve the size of any object. Here's an example of the same. import...

Hello reader! Whenever a client sends a request to the server, the response always contains a status code. You might not see it always but it's returned at every client-server interaction. Well, even if you are not a programmer, you would still know...

Hello reader! Microsoft subsidiary GitHub launched Copilot to power pair programming with AI. In this blog post, I will share all you need to know about it. You can refer to my YouTube video Tutorial to see a working tutorial for better understandin...

In this Blog article, we will learn how to Create a heart with Turtle, we will see the implementation in Python.
Repository for Ultimate Resource in python. Drop a star if you find it useful! Got anything to add? Open a PR on the same!
You can refer to my YouTube video tutorial for better Understanding:
1. Turtle Introduction
2. Creating a heart with Turtle
Turtle is a pre-installed Python library. It that enables users to create pictures and shapes by providing them with a virtual canvas. The onscreen pen that you use for drawing is called as turtle.
The turtle has three attributes: a location, an orientation (or direction), and a pen.
The turtle can move in four directions:
If you wish to know more about it, you can refer to Turtle Documentation. Use this link to navigate to the documentation.
Now that you are aware of Turtle basics, we can move forward to the coding section.
You can find all the code at my GitHub Repository. Drop a star if you find it useful.

In order to access the Python library, you need to import it into your Python environment, use the following command to import turtleit in your python script.
import turtle
Now let's define some properties,
3 using speed method, that means the heart will not just appear on the screen, the drawing will have some animation. bgcolor method, by default it is white. pensize method, it will be slightly bold.turtle.speed(3)
#turtle.bgcolor("black")
turtle.pensize(3)
Now let's define a function to define the curve, I am calling it as myfunc.
def curve():
for i in range(200):
turtle.right(1)
turtle.forward(1)
turtle.color("black", "red")
turtle.begin_fill()
turtle.left(140)
turtle.forward(111.65)
curve()
I will define a loop here for the first curve, we will set the direction right and move forward. Now let's set the turtle color using the color method
blackred is the color used to fill inside our heart.And once we have set the color, we can begin the fill using begin_fill method.
we call left and forward and finally call our function to get the first curve. It will look something like this.

turtle.left(120)
In order to change the pen's direction, use left method.

curve()
Now let's call the curve function again.

turtle.forward(111.65)
turtle.end_fill()
Let's make it touch the starting point and complete our heart. We will make use of forward method here. Once our heart is completed, we can now use end_fill to fill color in our heart.

If you closely observed you can see the pen head at the end. We will use hideturtle method to get red of it.
turtle.hideturtle()
turtle.done()
done method is used to hold the output Turtle screen.
This is all about Creating a heart with Turtle. That's it! simple, isn't it? Hope this tutorial has helped.
You can find all the code at my GitHub Repository. Drop a star if you find it useful.
Thank you for reading, I would love to connect with you at Twitter.
Do share your valuable feedback and suggestions!
You should definitely check out my other Blogs:
See you in my next Blog article, Take care