1. 程式人生 > >python 的turtle 簡易畫圖,第一次

python 的turtle 簡易畫圖,第一次

n) 一次 3.1 imp length circle python pre range

import turtle

bob = turtle.Turtle()

#畫四方形
def square(t,length):


for i in range(4):
t.lt(90)
t.fd(length)

square(bob,200)

#畫多邊形
def polygon(t,length,n):


for i in range(n):

t.lt(360/n)
t.fd(length)


polygon(bob,50,30)


#畫圓形
def circle(t,r):

for i in range(1000):
t.lt(360 / 1000)
t.fd(3.14*2*r/1000)

circle(bob,100)

python 的turtle 簡易畫圖,第一次