Question: HELP Python code won't run full program. Here is my code, the first part runs well. However, it won't execute or display the age in
HELP Python code won't run full program. Here is my code, the first part runs well. However, it won't execute or display the age in hours.
Anyone know what the error is?
#age_calc.
py # # Program 5 # # Purpouse: calcualtes hte approzimate nubmer of days/hours a person # has lived. Very Crude calcualtion # #author: Annon # DAYS_IN_YEAR = 365 def banner(): # this function prints our banner print('------------------ ') print(' Age Calc ') print('-----------------')
def daysToHours(days): # takes number of days and returns corresponding # hours. If days is less than zero, returns 0
hours = 0 if days >= 0: hours = days * 24 return hours
# calling the banner function banner() # get user's age age = int(input('How old are you?'))
days_lived = age * DAYS_IN_YEAR
# Print out stats print('you have lived approximately %d days.' %days_lived) print('Or alternatlively have lived approximatley %d hours.' %days_To_Hours(days_lived)) #print the banner banner
#agc_cal:4.ps. NamcError name 'days To Hours is not defined Python doesn t know what days_io Hours stands or L Did you torget to import it? e Has Python executed the detinition? B #BUthor : Arnon 18 DAYE IN YEAR 365 print(. /.ge Ca1 . print( May hu'p yu the couse of ihe aIc E Line 20: Either all return statements in a funiction should retum an def deysToHourstdays expression, or nene of them should. E Line 20: Unused variable 'daysToHcurs E Line 41 : Name 'days_ Hours' is not defined Line:Statement seems to have no ettect t takes rusher ot dsys snd returrs corresponding hours -days 24 32 baneer) 35 ag2int(Input( Hon old ane you Shell >>> %Run py.py
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
