猫史档案馆


【Python作品分享】bmi计算机【作品秀】

用户:VINSING渺宸VINSING渺宸查看:0 回复:3 评论:0 创建时间:2021-04-16T10:37:47


【作品展示】

center_image

 

【作品介绍】

六子

 

【作品源代码】

import turtle

#男生标准
light = 14.6
heavy = 21.8
fat = 24.5

#计算 BMI 值
myscreen = turtle.Screen()
height = float(myscreen.textinput("身高","请输入身高(m):"))
weight = float(myscreen.textinput("体重","请输入体重(kg):"))
bmi=weight / (height * height)
print(bmi)

# BMI 判断
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


回复

上一页1 页 / 共 1下一页
mornwindmornwind

定制课学员吗?

G6线第八课

点赞0


评论


云游box3der尖头叉子云游box3der尖头叉子

谁是G5的学员

点赞0


评论


VINSING渺宸VINSING渺宸

yes、、

 

 

点赞0


评论