Home >Backend Development >Python Tutorial >Python draws a five-pointed star
drawing a five-pointed star with Python
Share a small case of a five-pointed star drawn using Python. Welcome to leave a message to discuss and make corrections. Boss, don’t spray, hold your fists
The following is a small code
Code:
import turtle #导入turtle库包 turtle.fillcolor("red") #填充颜色 turtle.begin_fill() #开始画,类似起笔 count = 1 #计时器,用于计录次数 while count <= 5: #控制绘制次数 turtle.forward(100) #画笔绘制的方向,向前移动指定的距离 turtle.right(144) #向右转144度 count += 1 #循环绘制 turtle.end_fill() #完成填充图片的绘制。
Effect:
##Manypython training video, all on the python learning website, welcome to learn online!
The above is the detailed content of Python draws a five-pointed star. For more information, please follow other related articles on the PHP Chinese website!