Home >Backend Development >Python Tutorial >How to draw a smiley face using python

How to draw a smiley face using python

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼Original
2019-06-12 16:27:3315625browse

How to draw a smiley face using python? First we need to download and install the python program, and then download and install the turtle package. After all the preparations are done, we can start our next painting work.

How to draw a smiley face using python

#1. Find the python IDLE tool on our own computer.

How to draw a smiley face using python

2. Then open IDLE, create a new file, and name it test1.py.

Related recommendations: "Python Video Tutorial"

How to draw a smiley face using python

3. Then we start importing the turtle library and then edit the code.

from turtle import *
penup()
goto(0,-200)
pendown()
circle(200)
penup()
goto(-100,50)
pendown()
begin_fill()
circle(17.5)
end_fill()
penup()
goto(100,50)
pendown()
begin_fill()
circle(17.5)
end_fill()
penup()
goto(0,50)
pendown()
circle(-70,steps=3)
penup()
goto(-150,-70)
pendown()
right(15)
goto(0,-170)
goto(150,-70)
hideturtle()

4.F5 run the code and view the renderings.

How to draw a smiley face using python

The above is the detailed content of How to draw a smiley face using 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