Python实现绘制五角星

import turtle  # 导入turtle库包
def wjx(color,lenght=0):
turtle.fillcolor(color) # 填充颜色
turtle.begin_fill() # 开始画,类似起笔
count = 1 # 计时器,用于计录次数
while count <= 5: # 控制绘制次数
turtle.forward(lenght) # 画笔绘制的方向,向前移动指定的距离
turtle.right(144) # 向右转144
count += 1 # 循环绘制

turtle.end_fill() # 完成填充图片的绘制。
turtle.done()

def main():
color=input("请输入五角星颜色:")
lenght=eval(input("请输入五角星边长:"))
wjx(color,lenght)
main()
posted @ 2020-08-16 21:24  0刘家三少0  阅读(780)  评论(0)    收藏  举报