猫史档案馆


【Python作品分享】BMI计算器

用户:查看:0 回复:1 评论:0 创建时间:2021-10-31T12:11:55


【作品展示】

center_image

 

【作品介绍】

半成品

 

【作品源代码】

import turtle

light=14.6
heavy=21.8
fat=24.5

height=1.42
weight=40.5
BMI=weight/(height*height)
print(BMI)

if BMI<=light:
    print("偏瘦")
elif BMI<=heavy:
    print("正常")
elif BMI<=fat:
    print("超重")
else:
    print("肥胖")

mypen=turtle.Pen()
mypen.pensize(20)
mypen.pencolor("skyblue")
mypen.forward((light-10)*20)
mypen.pencolor("lightgreen")
mypen.forward((heavy-light)*20)
mypen.pencolor("coral")
mypen.forward((fat-heavy)*20)
mypen.pencolor("indianred")
mypen.forward((3)*20)

mypen.penup()
mypen.goto((BMI-10)*20,0)
mypen.dot(15,"gold")

mypen.hideturtle()
turtle.done()

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
小麦做的面包小麦做的面包

G6-1第8课

点赞0


评论