自学内容网 自学内容网

基于python绘制一个五角星

一、程序

import turtle


def draw_star(size, color):
    angle = 144
    turtle.fillcolor(color)
    turtle.begin_fill()
    for side in range(5):
        turtle.forward(size)
        turtle.right(angle)
    turtle.end_fill()


turtle.speed(1)  # 设置绘图速度,1为最慢
draw_star(100, "yellow")  # 绘制一个大小为100,颜色为黄色的五角星
turtle.done()

二、运行效果


原文地址:https://blog.csdn.net/weixin_45770896/article/details/142911598

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!