Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python BMI计算器我无法解决这个问题。_Python_Calculator - Fatal编程技术网

Python BMI计算器我无法解决这个问题。

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

因此,当我运行程序时,我得到了这个错误,我不确定为什么这不起作用

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 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。我还在想办法如何在这里发布。