# 实验8

 1 from turtle import *
2 def square(size=50,rgb='pink'):
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,'orange')
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 n=10
5 for i in range(n):
6     for j in range(2):
7         circle(80,90)
8         left(90)
9     right(360/n)
10 hideturtle()
11 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=10
9 for i in range(n):
10     for j in range(4):
11         fd(size)
12         angle+=72
13         seth(angle)
14         size+=5
15 hideturtle()
16 done()

 1 from turtle import *
2 from random import random
3 setup(800,600)
4 speed(0)
5 def rect(wide,high):
6     rgb=tuple(random() for i in range(3))
7     color(rgb)
8     begin_fill()
9     fd(wide)
10     left(90)
11     fd(high)
12     left(90)
13     fd(wide)
14     left(90)
15     fd(high)
16     left(90)
17     fd(wide)
18     end_fill()
19 for i in range(20):
20     rect(10,20)
21 hideturtle()
22 done()

posted @ 2022-06-13 23:04  炸呼  阅读(4)  评论(0编辑  收藏  举报