Python中的 turtle.circle() 方法
Turtle 模块以面向对象和面向过程的方式提供海龟图形原语。因为它使用 Tkinter 作为底层图形,所以它需要安装一个支持 Tk 的Python版本。
龟.圆():
此方法用于绘制具有给定半径的圆。
Syntax: turtle.circle(radius, extent=None, steps=None)
Parameters:
- radius: Radius of the circle.
- extent: The part of the circle in degrees as an arc.
- steps: Divide the shape in the equal number of given steps.
以下是上述方法的实现以及一些示例:
示例 1:
Python3
# importing turtle package
import turtle
# draw circle of radius
# 80 pixel
turtle.circle(80)
Python3
# importing turtle package
import turtle
# draw circle of radius 80
# pixel and extent = 180
# so it draw half circle
turtle.circle(80,
extent = 180)
Python3
# importing turtle package
import turtle
# draw circle of radius 80
# pixel and steps = 5
# so it draw pentagon with
# equal length 5 sides
turtle.circle(80,
steps = 5)
输出:
示例 2:
Python3
# importing turtle package
import turtle
# draw circle of radius 80
# pixel and extent = 180
# so it draw half circle
turtle.circle(80,
extent = 180)
输出:
示例 3:
Python3
# importing turtle package
import turtle
# draw circle of radius 80
# pixel and steps = 5
# so it draw pentagon with
# equal length 5 sides
turtle.circle(80,
steps = 5)
输出 :