Feb-24-2017, 07:50 AM
My first code is:
Thank you!
def GetAge(): print("How old are you? ") Years = float(input()) return Years def GetMonths(Years, Months): Months = Years * 12 return Months def GetDays(Years, Days): Days = Years * 365 return Days def GetHours(Years, Hours): Hours = Years * 365 * 24 return Hours def GetSeconds(Years, Seconds): Seconds = Years * 365 * 24 * 60 * 60 return Seconds def DisplaysResults(Months, Days, Hours, Seconds): print("This displays your age in months " + str(Months)) print("This displays your age in days " + str(Days)) print("This displays your age in hours " + str(Hours)) print("This displays your age in seconds " + str(Seconds)) #Main #This Program This program is divided into 3 modules/fuction(input, output and displays). The reason for this is to keep track of each step and not make it complicated. Years = GetAge() Months = GetMonths(Years, Months) Days = GetDays(Years, Days) Hours = GetHours(Years, Hours) Seconds = GetSeconds(Years, Seconds) print(Years, Months, Days, Hours, Seconds)The error is :
Error:Traceback (most recent call last):
File "python", line 32, in <module>
NameError: name 'Months' is not defined
The other code is:def GetMiles(): print("How far are you from your distance in Miles? ") Miles = float(input()) return Miles def GetYards(Yards, Miles): Yards = Miles * 1760 return Yards def GetFeet(Feet, Miles): Feet = Miles * 5280 return Feet def GetInches(Inches, Miles): Inches = Miles * 63360 return Inches def DisplayResults(Yards, Feet, Inches): print("Your destination in miles convert to yards is this" + "=" + str(yards)) print("Your destination in miles convert to feet is this" + "=" + str(feet)) print("Your destination in miles convert to inches is this" + "=" + str(inches)) print(" Drive safe" + " and " + "have a nice trip") #Main Miles = GetMiles() Yards = GetYards(Yards, Miles) Feet = GetFeet(Feet, Miles) Inches = GetInches(Inches, Miles) print(Yards, Feet, Inches)The error is:
Error:Traceback (most recent call last):
File "python", line 23, in <module>
NameError: name 'Yards' is not defined
It's pretty much the same error but different code, so can you help me?Thank you!