Python BMI计算器我无法解决这个问题。
因此,当我运行程序时,我得到了这个错误,我不确定为什么这不起作用 C:\Python27>python bmi.py 文件“bmi.py”,第11行 def getweight(重量) ^ SyntaxError:无效语法Python BMI计算器我无法解决这个问题。,python,calculator,Python,Calculator,因此,当我运行程序时,我得到了这个错误,我不确定为什么这不起作用 C:\Python27>python bmi.py 文件“bmi.py”,第11行 def getweight(重量) ^ SyntaxError:无效语法 print('BMI Calculator!') #declaring my variables ht=height wt=weight bm=bmi #Calling my main function main() #getting user input for weig
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()
在函数声明的末尾需要一个冒号。像这样:
def foo(bar):
pass
您有许多问题:缩进不正确、缺少
def
语句的冒号以及未定义的变量。请通读Python教程。感谢添加了冒号,缩进是正确的,它只是在代码的复制粘贴上看起来像foobar。我还在想办法如何在这里发布。