Advertisement
nosthemerc

wagecalc_v1

Nov 17th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.82 KB | None | 0 0
  1. #Variables used in time based calculation
  2. WEEKS_IN_YEAR = 56
  3. MONTHS_IN_YEAR = 12
  4. WEEKS_IN_MONTH = 4.5
  5.  
  6. #Can't figure out how to call upon local values.
  7. #Here is the error:
  8. #  File "WageCalc.py", line 44, in Main
  9. #    CalculateWages(wage_per_hour, hours_per_week)
  10. #NameError: global name 'wage_per_hour' is not defined
  11.  
  12.  
  13. def GetWage():
  14.     print "What's your hourly rate?"
  15.     wage_per_hour = int(raw_input(">> $"))
  16.     print "How many hours do you work per week?"
  17.     hours_per_week = int(raw_input(">> "))
  18.     return wage_per_hour, hours_per_week
  19. def GetExpences():
  20.     print "What is your monthly rent?"
  21.     rent_per_month = int(raw_input(">> $"))
  22.     print "What do your monthly bills typically amount to?"
  23.     bills_per_month = int(raw_input(">> $"))
  24.     monthly_expences = rent_per_month + bills_per_month
  25.     yearly_expences = monthly_expences * MONTHS_IN_YEAR
  26.     return monthly_expences, yearly_expences
  27.  
  28. def CalculateWages(wage_per_hour, hours_per_week):
  29.     weekly_paycheck = wage_per_hour * hours_per_week
  30.     monthly_wage = weekly_paycheck * WEEKS_IN_MONTH
  31.     yearly_income = weekly_paycheck * WEEKS_IN_YEAR
  32.     return weekly_paycheck, monthly_wage, yearly_income
  33.  
  34. def SubtractExpences(monthly_wage, yearly_income,
  35.     monthly_expences, yearly_expences):
  36.     monthly_net_total = monthly_wage - monthly_expences
  37.     yearly_net_total = yearly_income - yearly_expences
  38.     return monthly_net_total, yearly_net_total
  39.  
  40.  
  41. def Main():
  42.     GetWage()
  43.     GetExpences()
  44.     CalculateWages(wage_per_hour, hours_per_week)
  45.     SubtractExpences(monthly_wage, yearly_income,
  46.     monthly_expences, yearly_expences)
  47.     print("""
  48.         You make
  49.         $%s per month and
  50.         $%s per year.
  51.  
  52.         After bills, your net income is
  53.         $%s per month and
  54.         $%s per year
  55.         so plan accordingly.
  56.         """) % (monthly_wage, yearly_income,
  57.         monthly_net_total, yearly_net_total)
  58.     raw_input("RETURN to close")
  59.  
  60. Main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement