Draw Heart With Name Using Python

Draw Heart: Using Turtle Graphics Python 2023

Draw Heart Using Turtle Graphics Python 

Draw Heart With Name Using Python

Hello coders!!!  how are you?  Today we will draw a heart for ourselves using the Turtle module in Python, and we will give instructions to the turtle about what to draw. You can impress or propose this project to your friend, he will be very happy after seeing it.

Let’s go the project:-

The turtle can move in four directions:

  • Forward
  • Backward
  • Left
  • Right

1. step: Designing the Heart of Your Code

import turtle

turtle.pensize(3)
turtle.speed(30)  
def draw_heart_curve():
    for i in range(200):
        turtle.right(1)
        turtle.forward(1)
turtle.color("pink", "red")

OutPut:-

Draw Heart With Name Using Python

In this line, we are prepared our canvas and the turtle graphics module is import the screen is created with a white background

turtle.begin_fill()

turtle.left(140)
turtle.forward(111.65)
draw_heart_curve()
turtle.left(120)
draw_heart_curve()
turtle.forward(111.65)

turtle.end_fill()

OutPut:-

Draw Heart With Name Using Python

To make our turtle draw a heart shape we need to follow these commands.

3 step: Adding Your Name
turtle.color('blue')
style = ('Comic Sans MS', 30, 'italic')
turtle.write('CodeWithRandom', font=style, align='center')


turtle.hideturtle()
turtle.done()

done method is used to hold the output Turtle screen.

Final OutPut: –

Draw Heart: Using Turtle Graphics Python

 

Here is Complete Code Of Draw Heart With Name Using Python:-

import turtle turtle.pensize(3) turtle.speed(30)   def draw_heart_curve():     for i in range(200):         turtle.right(1)         turtle.forward(1) turtle.color("pink", "red") turtle.begin_fill() turtle.left(140) turtle.forward(111.65) draw_heart_curve() turtle.left(120) draw_heart_curve() turtle.forward(111.65) turtle.end_fill() turtle.color('blue') style = ('Comic Sans MS', 30, 'italic') turtle.write('CodeWithRandom', font=style, align='center') turtle.hideturtle() turtle.done()

Final OutPut Video :-

Thanks for reading my article —  This project not only introduce you to turtle graphics but we also combine programming with creativity. Now, you run your code and watch as Python transform into your Idea.

Happy coding and drawing! stay with us.

visit my more article:- codewithrandom

Author:- Ashutosh Mishra

FAQs:-

Which function is used to insert text in this program?

The turtle.write function is used to add text to this program.
Complete code to run this function:-
turtle.write('CodeWithRandom', font=style, align='center')

Which function you will use to change the colour of the turtle?

To change the color of the turtle use turtle.color() function.
Complete code to run this function:-
turtle.color("pink")



Leave a Reply