实验八

 1 from turtle import *
 2 def square(size=50,rgb='orange'):
 3     pencolor(rgb)
 4     for i in range(4):
 5         fd(size)
 6         left(90)
 7 def main():
 8     setup(800,600)
 9     speed(0)
10     n=10
11     for i in range(n):
12         square(80)
13         left(360/n)
14     hideturtle()
15     done()
16 if __name__=='__main__':
17     main()

 1 from turtle import *
 2 setup(800,600)
 3 pencolor('pink')
 4 
 5 n=10
 6 for i in range(n):
 7     for j in range(2):
 8         circle(80,90)
 9         left(90)
10 
11     right(360/n)
12 
13 hideturtle()
14 done()

 1 from turtle import *
 2 setup(800,600)
 3 bgcolor('black')
 4 pencolor('white')
 5 speed(0)
 6 angle=0
 7 size=2
 8 n=8
 9 for i in range(n):
10     for j in range(5):
11         fd(size)
12         angle+=72
13         seth(angle)
14         size+=5
15 hideturtle()
16 done()

from turtle import *
from random import random
def moveto(x,y):
    penup()
    goto(x,y)
    pendown()
setup(800, 600)
def rect(wide,height,rgb='red'):
    rgb = tuple(random() for i in range(3))
    color(rgb)
    for i in range(2):
        begin_fill()
        fd(wide)
        left(90)
        fd(height)
        end_fill()
        left(90)
for i in range(20):
    moveto((9 - i) * 10, 0)
    rect(10, 20)
hideturtle()
done()
复制代码

 

posted @ 2022-06-14 10:16  张博睿  阅读(4)  评论(0编辑  收藏  举报