将int转换为float并将int转换为字符串python2.7时出现问题

时间:2019-05-12 09:26:06

标签: python python-2.7

我尝试了几种方法来解决我遇到的问题。 没有十进制数字,我的程序运行良好。

我想要一个带小数点的答案。

因此,每次我输入小数点时,都会出现错误。  这是我尝试过的:

    from __future__ import  division
def bmi ():   ##  bmi = body mass index
    print " program to calculate person BMI"
    name = raw_input(" Hi welcome , what is your name ? : ")
    print " welcome %s " % name 
    weight = raw_input (" your weight(kg) : ")
    height = raw_input  ("your height (m): ")
    bmi =  int(weight)
    bmi_1 = int(height)
    if bmi/bmi_1**2 <= (25): 
        print " your ibm is : %d , you are not overweight "%(  bmi/bmi_1**2)
    elif  bmi/bmi_1**2 >= 24:
         print " your iibm is : %d  , sorry you are overweight" % (  bmi/bmi_1**2)
    else :
         print " sorry mistake, try again  "

1 个答案:

答案 0 :(得分:0)

float()

str()

可以解决问题。

相关问题