0

I have a part of my code where the first function adds all the values in a dictionary and another function that divides each value from the overall value which means that the summary should all equal to 100 however I have this situation where the last value does not divide properly:

 dict = {'Cancelled': 31, 'Accepted': 145, 'Expired': 128, 'Rejected': 779}
 overall = 1083.0
 general_status_summary = {'Cancelled': 2.8624192059095108, 'Accepted': 13.745868405204407, 'Expired': 13.858688982866132, 'Rejected': 96.236168061830412}

As you can see, the rejected key is not correct but the other three are right. I am confuse as to why this is. Here is my code below:

 status_summary = statusSummary(2014, 04, 1, 2015, 03, 31)

    def overall(dict):
        overall_number = sum(dict.values())
        return float(overall_number)    

    overallstatus = overall(status_summary)

    def summaryPercentage(dict):
        for key, value in dict.items():
            dict[key] = (value/(overall(dict))) * 100
        return dict

    general_status_summary = summaryPercentage(status_summary)

0 Answers0