Home > Backend Development > Python Tutorial > How to draw pictures using python

How to draw pictures using python

(*-*)浩
Release: 2019-07-09 10:20:02
Original
28478 people have browsed it

For students who have just learned programming, they are very unfamiliar with programming and a lot of codes. We who are busy studying in high school can even say that we know nothing about programming. Only when we enter university can we enter this major. I started to get into programming only after I started to come into contact with many computer-related things. Now I will teach you how to use programming language to draw pictures. Taking Python language as an example, we use Python to draw a heart this time.

How to draw pictures using python

##turtle drawing(Recommended learning: Python video tutorial)

turtle drawing is python A simple drawing tool introduced in , drawing using the turtle module is also called turtle drawing, because the drawing process can be seen as the walking track of a small turtle. The turtle is like a paintbrush on the screen, and the screen is the canvas.

from turtle import *
#我们将建立一个画薄,建立好画薄之后我们才能够在上面作画

setup(500,500)
#我们现在选择绘画笔的颜色和填充颜色

pencolor('pink')
fillcolor('red')
#我们先将开始和结束的代码写上去

begin_fill()
end_fill()
#我们开始填写中间的代码

left(140)
forward(111.65)

for i in range(200):
    right(1)
    forward(1)

left(120)

for i in range(200):
    right(1)
    forward(1)
forward(111.65)
#我们还要将画笔放下,然后将画笔隐藏起来

hideturtle()
done()
Copy after login
In the process of writing code, you must pay attention to checking the code, pay attention to checking symbol errors, and pay attention to whether the space indentation is correct. The most important thing is that all codes must be written in English, otherwise Will run without results. We must strengthen the practice of coding so that it will be more conducive to our learning of programming.

For more Python related technical articles, please visit the

Python Tutorial column to learn!

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