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

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

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

 1 from turtle import *
2 from random import random
3 setup(800, 600)
4 speed(0)
5
6 def rect(w, h, fc):
7     fillcolor(fc)
8     for i in range(1, 5):
9         if i % 2 == 1:
10             d = w
11         else:
12             d = h
13         fd(d)
14         left(90)
15 def moveto(x, y):
16     penup()
17     goto(x, y)
18     pendown()
19
20 for i in range(10):
21     moveto(20 * i, 0)
22     rgb = tuple(random() for i in range(3))
23     begin_fill()
24     rect(20, 50, rgb)
25     end_fill()
26 for i in range(10):
27     moveto(-20 * i, 0)
28     rgb = tuple(random() for i in range(3))
29     begin_fill()
30     rect(20, 50, rgb)
31     end_fill()
32
33 hideturtle()
34 done()

posted on 2022-06-13 16:18  starry。  阅读(3)  评论(0编辑  收藏  举报