My first code is:
The error is :
The error is:
Thank you!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
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) |
Error:Traceback (most recent call last):
File "python", line 32, in <module>
NameError: name 'Months' is not defined
The other code is:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
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) |
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!