首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >我的体重指数计算器向后运行

我的体重指数计算器向后运行
EN

Stack Overflow用户
提问于 2018-06-11 00:52:56
回答 1查看 56关注 0票数 -1

我正在为学校编写的Bmi计算器向后产生我的输出,它首先调用用户信息,然后调用名称信息。请帮帮忙,我需要的是相反的方式。

代码语言:javascript
复制
user = str
end = False

def bmi_intro():
    print("BMI Calculator")
    while end == False:


        user = input("Enter students name or '0' to quit: ")
        if user == "0":
            print("end of report!")
        else:
            def userName(str):
                user = str
            print("Lets gather your information,", user)
            break

    get_height = float(input("Please enter your height in inches: "))
    get_weight = float(input("Please enter your weight: "))
    body_mass_index = (get_weight * 703) / (get_height ** 2)
    print ("Your bmi is: ", body_mass_index)

def main():
  get_height = 0.0
  get_weight = 0.0
  body_mass_index = 0.0
bmi_intro()
EN

回答 1

Stack Overflow用户

发布于 2018-06-11 00:58:44

更正缩进和删除break语句可以解决您的问题(我已经尝试尽可能少地编辑您的代码,我认为这将有助于您理解代码):

代码语言:javascript
复制
user = str
end = False

def bmi_intro():
        print("BMI Calculator")
        while end == False:


        user = input("Enter students name or '0' to quit: ")
        if user == "0":
            print("end of report!")
            break
        else:
            def userName(str):
                user = str
            print("Lets gather your information,", user)


            get_height = float(input("Please enter your height in inches: "))
            get_weight = float(input("Please enter your weight: "))
            body_mass_index = (get_weight * 703) / (get_height ** 2)
            print ("Your bmi is: ", body_mass_index)

def main():
  get_height = 0.0
  get_weight = 0.0
  body_mass_index = 0.0
bmi_intro()
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50785979

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档