Home  >  Article  >  Backend Development  >  How to draw a heart in python

How to draw a heart in python

尚
Original
2019-07-01 14:46:2730225browse

How to draw a heart in python

Python can use the turtle library to draw hearts. The Turtle library is a very popular function library for drawing images in the Python language. Imagine a little turtle, starting at the origin of a coordinate system with the horizontal axis as x and the vertical axis as y, (0,0). It uses a set of functions The control of the instruction moves in this plane coordinate system, thereby drawing graphics on the path it crawls.

The implementation code is as follows:

from turtle import *
pensize(1)
pencolor('red')
fillcolor('pink')
speed(5)
up()
goto(-30, 100)
down()
begin_fill()
left(90)
circle(120,180)
circle(360,70)
left(38)
circle(360,70)
circle(120,180)
end_fill()
up()
goto(-100,-100)
down()

The effect is as follows:

How to draw a heart in python

##For more Python related technical articles, please visit

Python Tutorial column for learning!

The above is the detailed content of How to draw a heart in python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn