[Tutor] Calaculating a monthly total of earning

walter weston hacker0100 at hotmail.com
Mon Jan 17 00:40:20 CET 2011


Heres my code:

def income_report(yearly_income,hourly_income):
    """ this will count the average of your total monthly income"""
    sum_of_monthly=int(yearly_income/12)# his yearly income dividing by 12.
    minus_weekends=hourly_income*64 #the 64 is the two days off for the weekend(assuming working an 8 hour shift)
                                                          #and there are 4 weekends in a month so 1 weekend=16 hours so 4 weekends would be 64 hours now working
                                                          #now I must subtract that from the monthly income(sum_of_monthly)
    total_income=int(minus_weekends-sum_of_monthly) #this is the money thats subtracted to the monthly total not working from the weekends
    return sum_of_monthly,total_income

I call income_report with some like income_report(200000,12) and I get numbers printed like (16666, -15898) the second argument is to much and its negative and when I multiply 16666 by 12 to see if sum_of_monthly did its job correctly I get a number thats off , I got 199992 not 200000.Python is so tempormential what is wrong with my code?

 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110116/ac05b793/attachment.html>


More information about the Tutor mailing list