Skip to content

Instantly share code, notes, and snippets.

@jexchan
Last active December 20, 2019 09:29
Show Gist options
  • Save jexchan/3e3d7e26e5e92fdc17c20e626bf504e0 to your computer and use it in GitHub Desktop.
Save jexchan/3e3d7e26e5e92fdc17c20e626bf504e0 to your computer and use it in GitHub Desktop.
Python Turtle 精讲 example02
#定义画多边形函数
import turtle
t = turtle.Turtle() #命名一个简化的名称
t.shape('turtle') #设定小光海龟来画图
# t.speed(0)
def polygon(length, sides):
for i in range(sides):
t.forward(length)
angle = 360 / sides
t.right(angle)
polygon(100, 5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment