for循环:用turtle画一颗五角星


 

  

import turtle
#五角星

turtle.pencolor('yellow')
turtle.fillcolor('yellow')
turtle.begin_fill()

turtle.forward(100)
turtle.right(144)

turtle.forward(100)
turtle.right(144)

turtle.forward(100)
turtle.right(144)

turtle.forward(100)
turtle.right(144)

turtle.forward(100)
turtle.right(144)

turtle.end_fill()
turtle.done()

  

import turtle

turtle.bgcolor('red')
turtle.pencolor('yellow')
turtle.fillcolor('yellow')
turtle.begin_fill()

for i in range(5):
     turtle.forward(100)
     turtle.right(144)

turtle.end_fill()
turtle.done()

  

import turtle
turtle.pencolor('blue')
turtle.fillcolor('green')
turtle.begin_fill()

while True:
    turtle.forward(100)
    turtle.right(56)
    if (abs(turtle.pos()))<1:
        break

turtle.end_fill()
turtle.done()

posted @ 2018-05-09 21:02  mablenmx  阅读(206)  评论(0)    收藏  举报