Python BMI计算器我无法弄清楚这个问题。

时间:2015-12-17 20:58:10

标签: python calculator

所以当我运行程序时出现此错误,我不知道为什么这不起作用。

C:\ Python27> python bmi.py   文件“bmi.py”,第11行     def getweight(wt)                     ^ SyntaxError:语法无效

print('BMI Calculator!')
#declaring my variables
ht=height
wt=weight
bm=bmi
#Calling my main function
main()

#getting user input for weight in pounds
def getweight(wt)
    weight = int(input('Please enter your weight input pounds(whole number):    '))
return(wt)

#getting user input for height in inches
def getheight(ht)
    height = int(input('Please enter your height input in inches(whole number): '))  
return(ht)

#function for the bmi calculator 
def bmicalc()
    bmi = (wt*703)/(ht*ht)

#main function  
def main()
getweight()
getheight()
bmicalc()

1 个答案:

答案 0 :(得分:0)

您需要在函数声明的末尾添加冒号。像这样:

def foo(bar):
    pass