标签:port mat oop range input pytho turtle main 使用
import turtle
import time
import math
def polygon(bob,n,r):
jiaoDu = 360/n
juLi=2*r*math.sin(jiaoDu/180*math.pi/2)
bob.pu()
bob.fd(r)
bob.lt(90+jiaoDu/2)
bob.pd()
for i in range(n):
bob.fd(juLi)
bob.lt(jiaoDu)
time.sleep(0.5)
n=int(input("请输入边数:"))
r=float(input("请输入半径:"))
bob=turtle.Turtle()
polygon(bob,n,r)
turtle.mainloop()
标签:port mat oop range input pytho turtle main 使用
原文地址:http://www.cnblogs.com/zlfeng825/p/7440145.html