用Python写一个五角形,紫色

版本是3.7.3shell

For语句做

import turtle

turtle.color("purple","purple")
turtle.begin_fill()
for i in range(5):
    turtle.fd(100)
    turtle.right(144)
turtle.end_fill()
turtle.done()

import turtle

turtle.fillcolor("purple")
turtle.begin_fill()
while True:
    turtle.forward(220)
    turtle.right(144)
    if abs(turtle.pos()) < 1:
        break
turtle.fd(84)
for i in range(5):
    turtle.fd(52)
    turtle.right(72)
turtle.end_fill()
turtle.done()

 

import turtle

turtle.fillcolor("purple")
turtle.begin_fill()
while True:
    turtle.forward(220)
    turtle.right(144)
    if abs(turtle.pos()) < 1:
        break
turtle.fd(84)
for i in range(5):
    turtle.fd(52)
    turtle.right(72)
turtle.end_fill()
turtle.done()