Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Variables used in time based calculation
- WEEKS_IN_YEAR = 56
- MONTHS_IN_YEAR = 12
- WEEKS_IN_MONTH = 4.5
- #Can't figure out how to call upon local values.
- #Here is the error:
- # File "WageCalc.py", line 44, in Main
- # CalculateWages(wage_per_hour, hours_per_week)
- #NameError: global name 'wage_per_hour' is not defined
- def GetWage():
- print "What's your hourly rate?"
- wage_per_hour = int(raw_input(">> $"))
- print "How many hours do you work per week?"
- hours_per_week = int(raw_input(">> "))
- return wage_per_hour, hours_per_week
- def GetExpences():
- print "What is your monthly rent?"
- rent_per_month = int(raw_input(">> $"))
- print "What do your monthly bills typically amount to?"
- bills_per_month = int(raw_input(">> $"))
- monthly_expences = rent_per_month + bills_per_month
- yearly_expences = monthly_expences * MONTHS_IN_YEAR
- return monthly_expences, yearly_expences
- def CalculateWages(wage_per_hour, hours_per_week):
- weekly_paycheck = wage_per_hour * hours_per_week
- monthly_wage = weekly_paycheck * WEEKS_IN_MONTH
- yearly_income = weekly_paycheck * WEEKS_IN_YEAR
- return weekly_paycheck, monthly_wage, yearly_income
- def SubtractExpences(monthly_wage, yearly_income,
- monthly_expences, yearly_expences):
- monthly_net_total = monthly_wage - monthly_expences
- yearly_net_total = yearly_income - yearly_expences
- return monthly_net_total, yearly_net_total
- def Main():
- GetWage()
- GetExpences()
- CalculateWages(wage_per_hour, hours_per_week)
- SubtractExpences(monthly_wage, yearly_income,
- monthly_expences, yearly_expences)
- print("""
- You make
- $%s per month and
- $%s per year.
- After bills, your net income is
- $%s per month and
- $%s per year
- so plan accordingly.
- """) % (monthly_wage, yearly_income,
- monthly_net_total, yearly_net_total)
- raw_input("RETURN to close")
- Main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement