Python BMI 计算器我无法弄清楚这个问题。
Python BMI Calculator I cannot figure out the issue.
所以当我 运行 程序时出现这个错误,我不确定为什么这不起作用。
C:\Python27>python bmi.py
文件 "bmi.py",第 11 行
def getweight(重量)
^
语法错误:语法无效
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
所以当我 运行 程序时出现这个错误,我不确定为什么这不起作用。
C:\Python27>python bmi.py 文件 "bmi.py",第 11 行 def getweight(重量) ^ 语法错误:语法无效
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