Home  >  Article  >  Backend Development  >  How to draw a circle using python

How to draw a circle using python

(*-*)浩
(*-*)浩Original
2019-06-21 16:45:5327530browse

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()

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()

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!

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