我正在尝试为计算机科学课程完成这个程序,但我遇到了这个错误你好特里斯坦维纳。您是 0x101fe6050 岁的函数 personAge。为什么我得到而不是年龄?`#This program calculates a users age while collecting the user's #birth year, the user's first and last name, the current year #and whether the user has had their birthday yet. firstName = raw_input("Please enter your first name")#Get the first name lastName = raw_input("Please enter your last name")#Get the last name birthYear = int(input("What is your birth year?"))#Get the birth year currentYear = int(input("What is the current year?"))#Get the current yearbirthdayYet = raw_input("Have you had your birthday yet? [1 for yes/2 for no]")#Ask if the user has had their birthdayage = 0def fullName (firstName, lastName): outStr = firstName +" "+lastName return outStrdef personAge(birthYear, currentYear, birthdayYet): if birthdayYet == 1: print(currentYear - birthYear) if birthdayYet == 2: age = currentYear - birthYear - 1 return str(age)def printMsg(personName,personAge): return ("Hello" + " " + str(personName) + "." + " " + "You are" + " " + str(personAge) + " " + "years old.")personName = fullName(firstName, lastName)userAge = personAge(birthYear, currentYear, birthdayYet)finalMsg = printMsg(personName, personAge)print finalMsg`
添加回答
举报
0/150
提交
取消