Python 名称错误:名称';年龄';没有定义

Python 名称错误:名称';年龄';没有定义,python,python-3.x,nameerror,Python,Python 3.x,Nameerror,我对此已经研究了很长一段时间,但我不知道到底出了什么问题。我对Python比较陌生,因为它是通用的,所以它可能是一个简单的修复方法 def main(): age = 0; weight = 0; birthMonth = " "; getAge(); getWeight(); getBirth(); correct(); def getAge(): age = input("Guess the age.\t") retu

我对此已经研究了很长一段时间,但我不知道到底出了什么问题。我对Python比较陌生,因为它是通用的,所以它可能是一个简单的修复方法

def main():
    age = 0;
    weight = 0;
    birthMonth = " ";
    getAge();
    getWeight();
    getBirth();
    correct();

def getAge():
    age = input("Guess the age.\t")
    return age;
def getWeight():
    weight = input("Guess the weight.\t")
    return weight;
def getBirth():
    birthMonth = input("Guess the month.\t")
    return birthMonth;
def correct():
    if (age <= 25):
         print ("Congratulations, the age is 25 or less")
    else:
        print ("You did not correctly guess the age");
    if (weight <= 128):
        print ("Congratulations, the weight is 128 or more")
    else:
        print ("You did not correctly guess the weight");
    if (birthMonth == 25):
        print ("Congratulations, the month is April")
    else:
        print ("You did not correctly guess the month");
main();
def main():
年龄=0;
权重=0;
生日=”;
getAge();
getWeight();
获得出生();
正确的();
def getAge():
年龄=输入(“猜测年龄。\t”)
回归年龄;
def getWeight():
权重=输入(“猜测权重。\t”)
返回重量;
def getBirth():
生日月份=输入(“猜测月份。\t”)
返回出生月份;
def correct():
如果(年龄你试过这个吗

def main():
  age = getAge()
  weight = getWeight()
  birthMonth = getBirth()
  correct(age,weight,birthMonth)

def getAge():
  age = float(input("Guess the age.\t"))
  return age
def getWeight():
  weight = float(input("Guess the weight.\t"))
  return weight
def getBirth():
  birthMonth = input("Guess the month.\t")
  return birthMonth
def correct(age,weight,birthMonth):
  if age <= 25:
     print ("Congratulations, the age is 25 or less")
  else:
    print ("You did not correctly guess the age")
  if weight <= 128:
    print ("Congratulations, the weight is 128 or more")
  else:
    print ("You did not correctly guess the weight")
  if birthMonth == "April":
    print ("Congratulations, the month is April")
  else:
    print ("You did not correctly guess the month")

main()
def main():
age=getAge()
权重=getWeight()
birthMonth=getBirth()
正确(年龄、体重、出生月份)
def getAge():
年龄=浮动(输入(“猜测年龄。\t”))
回归年龄
def getWeight():
权重=浮动(输入(“猜测权重。\t”))
回重
def getBirth():
生日月份=输入(“猜测月份。\t”)
返回出生月
def正确(年龄、体重、出生月):

如果可能重复Please,Python代码中没有分号
。我试过了,但它给了我一个不同的错误,“TypeError:unorderable types:str()修复了它!需要eval(input(…)来修复”TypeError:unorderable types:str()@UzzuMakazaque:对数字使用
int
float
,而不是
eval
编辑。我猜您使用的是python3。python2可以使用原始输入,它可以工作directly@cromod,是的,我正在使用python3,我可能应该指定它。
def main():
  age = getAge()
  weight = getWeight()
  birthMonth = getBirth()
  correct(age,weight,birthMonth)

def getAge():
  age = float(input("Guess the age.\t"))
  return age
def getWeight():
  weight = float(input("Guess the weight.\t"))
  return weight
def getBirth():
  birthMonth = input("Guess the month.\t")
  return birthMonth
def correct(age,weight,birthMonth):
  if age <= 25:
     print ("Congratulations, the age is 25 or less")
  else:
    print ("You did not correctly guess the age")
  if weight <= 128:
    print ("Congratulations, the weight is 128 or more")
  else:
    print ("You did not correctly guess the weight")
  if birthMonth == "April":
    print ("Congratulations, the month is April")
  else:
    print ("You did not correctly guess the month")

main()