python

1.五角星

import turtle        
turtle.fillcolor("red")            
turtle.begin_fill()             
count = 1                        
while count <= 5:               
    turtle.forward(100)             
    turtle.right(144)             
    count += 1                  
turtle.end_fill()

 

 

2.六角形

import turtle 
turtle.pensize(2)
turtle.fillcolor("white")
turtle.begin_fill()
turtle.right(330)
turtle.forward(200)
for i in range(2):
    turtle.right(120)
    turtle.forward(300)
turtle.right(120)    
turtle.forward(100)
turtle.right(300)
turtle.forward(100)
for i in range(3):
    turtle.right(120)
    turtle.forward(300)
turtle.end_fill()
turtle.hideturtle()
turtle.done()

 

 3.叠加等边三角形

import turtle 
turtle.pensize(2)
turtle.fillcolor("white")
turtle.begin_fill()
for i in range(3):
    turtle.forward(100)
    turtle.right(120)
turtle.right(300)
turtle.forward(100)
for i in range(3):
    turtle.right(120)
    turtle.forward(200)
turtle.end_fill()
turtle.hideturtle()
turtle.done()

笔记

 

posted @ 2020-03-14 09:09  cjl1124  阅读(128)  评论(0)    收藏  举报