用户:
爱吃编程猫的喜羊羊查看:0 回复:0 评论:0 创建时间:2021-07-12T17:01:05
【作品展示】

【作品介绍】
能够计算你的身体质量指数的小程序
【作品源代码】
import turtle
#BMI 身体质量指数
myscreen=turtle.Screen()#(调用窗口函数)
light=14.6
heavy=21.8
fat=24.5
height=float(myscreen.textinput("身高","请输入你的身高(m):"))#使用窗口函数的textinput
weight=float(myscreen.textinput("体重","请输入你的体重(kg):"))
bmi=weight/(height*height)
if bmi<=light:
print("身材偏瘦")
elif bmi<=heavy:
print("正常体重")
elif bmi<=fat:
print("身材超重")
else:
print("身材肥胖")
#图像显示
mypen=turtle.Pen()
mypen.pensize(20)
#BMI范围
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