其他分享
首页 > 其他分享> > 实验八

实验八

作者:互联网

 1 from turtle import*
 2 
 3 def square(size=50,rgb='pink'):
 4     pencolor(rgb)
 5     for i in range(4):
 6         fd(size)
 7         lt(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,'orange')
17         left(360/n)
18 
19     hideturtle()
20     done()
21 
22 if __name__ == '__main__':
23     main()

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

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

 1 from turtle import*
 2 from random import random
 3 
 4 
 5 setup(800,600)
 6 pencolor('black')
 7 speed(0)
 8 
 9 
10 n = 100
11 for i in range(10):
12     rgb = tuple(random() for j in range(3))
13     color(rgb)
14     begin_fill()
15     rt(90)
16     fd(20)
17     lt(90)
18     fd(n)
19     lt(90)
20     fd(40)
21     lt(90)
22     fd(n)
23     lt(90)
24     fd(20)
25     lt(90)
26     end_fill()
27     n -= 10
28 
29 s = 100
30 for k in range(10):
31     rgb = tuple(random() for m in range(3))
32     color(rgb)
33     begin_fill()
34     rt(90)
35     fd(20)
36     rt(90)
37     fd(s)
38     rt(90)
39     fd(40)
40     rt(90)
41     fd(s)
42     rt(90)
43     fd(20)
44     lt(90)
45     end_fill()
46     s -= 10
47 done()

 

标签:10,20,实验,lt,range,fd,90
来源: https://www.cnblogs.com/shanweizhe/p/16365033.html