Home > Backend Development > Python Tutorial > How to draw a heart in python

How to draw a heart in python

Release: 2019-07-06 08:56:10
Original
30333 people have browsed it

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()
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template