bmi计算 python_Python中的BMI计算器
程序根据用户输入的体重和身高计算出一个人的体重指数。但是,输入“metric”或“imperial”并按enter键后,程序将关闭。前三个打印功能工作正常,之后的任何内容都不会在我按下回车键后出现。我该怎么解决?print('\t\t\t BMI Calculator')
print('\t\t\t By Abdinasir Hussein')
print('\n Hello, this is a BMI Calculator!')
input('Do you wish to enter metric units or imperial units: ')
while input == 'metric':
height = float(input('Please enter your height input meters(decimals): '))
weight = int(input('Please enter your weight input kg: '))
bmi = weight/(height*height)
if bmi <= 18.5:
print('Your BMI is', bmi,'which means you are underweight.')
elif bmi > 18.5 and bmi < 25:
print('Your BMI is', bmi,'which means you are normal.')
elif bmi > 25 and bmi < 30:
print('your BMI is', bmi,'overweight.')
elif bmi > 30:
print('Your BMI is', bmi,'which means you are obese.')
else:
print('There is an error with your input')
print('Please check you have entered whole numbers\n'
'and decimals were asked.')
while input == 'imperial':
height = int(input('Please enter your height input inputches(whole number): '))
weight = int(input('Please enter your weight input pounds(whole number): '))
bmi = (weight*703)/(height*height)
if bmi <= 18.5:
print('Your BMI is', bmi,'which means you are underweight.')
elif bmi > 18.5 and bmi < 25:
print('Your BMI is', bmi,'which means you are normal.')
elif bmi > 25 and bmi < 30:
print('Your BMI is', bmi,'which means you are overweight')
elif bmi > 30:
print('Your BMI is', bmi,'which means you are obese.')
else:
print('There is an error with your input')
print('Please check you have entered whole numbers\n'
'and decimals were asked.')
input('\n\nPlease press enter to exit.')
我现在已经更改了,但是如何编辑此块:input = input('Do you wish to enter metric units or imperial units: ')
if input == 'metric':
height = float(input('Please enter your height input meters(decimals): '))
weight = int(input('Please enter your weight input kg: '))
bmi = weight/(height*height)
if bmi <= 18.5:
print('Your BMI is', bmi,'which means you are underweight.')
elif bmi > 18.5 and bmi < 25:
print('Your BMI is', bmi,'which means you are normal.')
elif bmi > 25 and bmi < 30:
print('your BMI is', bmi,'overweight.')
elif bmi > 30:
print('Your BMI is', bmi,'which means you are obese.')
else:
print('There is an error with you inputput')
print('Please check you have entered whole numbers\n'
'and decimals where asked.')
bmi计算 python_Python中的BMI计算器相关推荐
- bmi编程python_Python中计算BMI的有效程序设计
我是编程新手,也处于初级阶段.我写了一个程序来计算BMI在这里的几个主题的帮助下.在 代码点评:是这样吗我已经在程序中使用了三次main函数,我认为编写bmi公式也可以更加有效,即避免将float转换 ...
- bmi计算 python_python tkinter bmi计算
试试看bmiheight=self.heightcm.get() print(bmiheight) bmiweight=self.weightkg.get() bmi= float((bmiweigh ...
- python实例练习(12)身体质量指数BMI计算
文章目录 简介 问题描述 完整代码 简介 身体质量指数,即BMI,是国际上常用于衡量人体肥胖程度以及是否健康的重要标准之一,主要用于统计分析.健康程度以及肥胖程度不能采用体重的绝对值,因此BMI能够通 ...
- 用tkinter实现BMI计算
import tkinter import tkinter.messageboxroot = tkinter.Tk() root.title('BMI计算器') root.geometry('400x ...
- Python中用tkinter实现BMI计算
import tkinter import tkinter.messageboxroot = tkinter.Tk() root.title('BMI计算器') root.geometry('400x ...
- AndroidStudio简单代码实现BMI计算
DAY1 xml代码 ```xml <TextViewandroid:id="@+id/textView"android:layout_width="match_p ...
- 根据身高体重计算某个人的BMI值--课后程序(Python程序开发案例教程-黑马程序员编著-第3章-课后作业)
实例3:根据身高体重计算某个人的BMI值 BMI又称为身体质量指数,它是国际上常用的衡量人体胖瘦程度以及是否健康的一个标准.我国制定的BMI的分类标准如表1所示. 表1 BMI的分类 BMI 分类 ...
- Flutter for App——一个简单的BMI计算APP
一个简单的BMI计算APP 效果截图 初始化 布局 顶部区域 标题 计算结果 组合顶部区域 背景 中间区域 输入框 输入行 计算按钮 分界线 组合中间区域 底部区域 页面组合 BMI计算 Toast弹 ...
- 熟悉安卓开发环境 之 BMI计算App
菜鸡记录一下学习安卓时做过的小项目. 酱酱~!! 本次是BMI计算app,超级简单的app,随便写着玩的. BMI指数(即身体质量指数,简称体质指数又称体重,英文为Body Mass Index,简称 ...
最新文章
- 暴力拒绝白嫖,著名开源项目作者删库跑路!神秘Bug影响超2万个项目,亚马逊云也躺枪...
- 第十三周项目一-分数类中的运算符重载
- Spark SQL入门示例
- java nextline没有停住_java中使用nextLine(); 没有输入就自动跳过的问题?
- 支持CDS view的SAP ALV IDA - 使用前提
- 参加胶东开发者技术大会有感
- [MEGA DEAL]完整的Java编程训练营(94%折扣)
- Doclava:来自Google的自定义Javadoc Doclet
- 【CodeForces - 208C 】Police Station(单源最短路条数,起点终点建图,枚举顶点)
- c#自动更新+安装程序的制作
- 观测云品牌正式亮相,携手通信院共推国内可观测性概念与技术发展!
- 基于ISM的大数据在建筑领域中的应用障碍分析
- Python代码模块化!
- pyhton中的wsgi是什么?
- java 显示图片的一部分_求只显示图片上半部分三分之一的写法
- java语言诞生的主要贡献者_2020年12月编程语言排行+GitHub 年度报告正式发布,JavaScript 霸榜、TypeScript 爆发!...
- Paper-----文献引用格式
- 双管道(CreatePipe)与本地cmd.exe进程通信(附源代码及编译好的程序,免费下载)
- Python自动化测试框架,谁才是你的唯一?
- uvaLive 4490 Help Bubu 帮助布布 等价转化+DP