# 实验八

 1 from turtle import *
2
3 def square(size=50, rgb='orange'):
9     pencolor(rgb)
10     for i in range(4):
11         fd(size)
12         left(90)
13
14
15 def main():
16     setup(800, 600)
17     speed(0)
18
19     n = 10
20     for i in range(n):
21         square(80)
22         left(360/n)
23
24     hideturtle()
25     done()
26
27
28 if __name__ == '__main__':
29     main()

 1 from turtle import *
2
3 setup(800, 600)
4 pencolor('pink')
5 speed(0)
6
7 n = 10
8 for i in range(n):
9     # 绘制一片花瓣
10     for j in range(2):
11         circle(80, 90)
12         left(90)
13
14     right(360/n)
15
16 hideturtle()
17 done()

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

from turtle import *
from random import random
setup(800, 600)
speed(0)

n=100
for i in range(10):
rgb = tuple( random() for i in range(3) )
color(rgb)
begin_fill()
lt(90)
fd(20)
lt(90)
fd(n)
lt(90)
fd(40)
lt(90)
fd(n)
lt(90)
fd(20)
rt(90)
n-=10
end_fill()

n=100
for i in range(10):
rgb = tuple( random() for i in range(3) )
color(rgb)
begin_fill()
rt(90)
fd(20)
lt(90)
fd(n)
lt(90)
fd(40)
lt(90)
fd(n)
lt(90)
fd(20)
lt(90)
n-=10
end_fill()
hideturtle()

done()

posted @ 2022-06-09 18:25  爱冒险的小洋  阅读(6)  评论(0编辑  收藏  举报