Python初学第一周

1 #五角星.py
2 import turtle as t
3 t.fillcolor("red")
4 t.begin_fill()
5 for i in range(5):
6     t.fd(200)
7     t.right(144)
8 t.end_fill()
9 t.done()

绘制五角星

示例:

绘制六角星

 1 #六角形.py
 2 import turtle as t
 3 n=300
 4 t.pencolor("yellow")
 5 t.pensize(15)
 6 t.seth(30)
 7 for i in range(3):
 8     t.fd(n)
 9     t.right(120)
10 t.up()
11 t.pencolor("pink")
12 t.fd(n/3)
13 t.seth(90)
14 t.fd(n/3)
15 t.seth(-90)
16 t.down()
17 for i in range(3):
18     t.fd(n)
19     t.left(120)
20 t.done()

示例:

绘制叠加等边三角形

 1 #叠三角.py
 2 import  turtle as t  
 3 def threeangle(x):
 4     for i in range(3):
 5         t.fd(x)
 6         t.right(120)
 7 n=400
 8 t.pensize(9)
 9 t.pencolor("brown")
10 t.seth(60)
11 threeangle(n)
12 t.fd(n/2)
13 t.seth(0)
14 t.pencolor("red")
15 threeangle(n/2)
16 t.done()

示例:

猜你喜欢

转载自www.cnblogs.com/nicefurmine/p/12463345.html