我在执行python<function personAge at 0x101fe6050>而不是value时收到一个错误
回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我试图完成计算机科学课程的这个程序,但我被这个错误卡住了</p>
<p>你好,特里斯坦·维纳。您是0x101fe6050岁的职能人士</p>
<p>为什么我会变老而不是变老</p>
<pre><code>`#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 year
birthdayYet = raw_input("Have you had your birthday yet? [1 for yes/2 for no]")
#Ask if the user has had their birthday
age = 0
def fullName (firstName, lastName):
outStr = firstName +" "+lastName
return outStr
def 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`
</code></pre>