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

How to draw a circle using python

(*-*)浩
Release: 2019-06-21 16:45:53
Original
27643 people have browsed it

There are many third-party libraries built into python to help it complete various functions.

How to draw a circle using python

The Turtle library is a very popular function library for drawing images in the Python language (recommended learning: Python video tutorial)

Turtl library is used to draw lines, circles, other shapes or text

This library is introduced as the most commonly used method library to introduce programming knowledge to children. It is mainly used It is an introduction to programming and is one of the standard libraries. Turtle can be used to create many complex drawings.

Understanding of Turtle Principle

The name turtle means "turtle". We imagine a turtle, located in the center of the form on the display, swimming on the canvas, and its swimming trajectory is The drawn graph is formed.
The movement of the turtle is controlled by the program, it can change color, change size (width), etc.

Draw a circle

import turtle
turtle.color('red')
turtle.circle(39)
turtle.done()
Copy after login

turtle.circle(radius,extent,step)

radius is required and represents the radius. When it is positive, it rotates counterclockwise;

extent represents the degree and is used to draw arcs;

step represents the number of sides and can be used to draw regular polygons;

extent and step parameters are optional.

Example 1

import turtle
turtle.color('orange')
turtle.pensize(3)
turtle.circle(75)
turtle.penup()
turtle.goto(0, -200)
turtle.pendown()
turtle.circle(100)
turtle.done()
Copy after login

For more Python related technical articles, please visit the Python Tutorial column to learn!

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