Turtle draws a five-pointed star in ten lines of code

Turtle is a very easy to use drawing library, concise and effective, drawing a five-pointed star only needs ten simple lines of code
Insert picture description here

import turtle as t
t.pensize(2)	# 画笔大小
t.pencolor("gray")	# 画笔颜色
t.fillcolor("gray")	# 填充颜色
t.begin_fill()	

Insert picture description here

After setting the parameters, traverse five times, and finally fill in the color
Insert picture description here

for _ in range(0, 5):
    t.forward(300)
    t.right(144)
t.end_fill()
t.mainloop()	# 维持画布

Insert picture description here
Simple drawing is done
Insert picture description here

Guess you like

Origin blog.csdn.net/JasonZ227/article/details/109955854