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:
##For more Python related technical articles, please visitPython 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!