import math class MathUtilMixin(object): def calculateDefaultActivityPercentages(self, number, decimals = 1): """Given a number of records it will return a tuple in the form (default_activity_percentage, last_activity_percentage)""" if number <= 1: return (100.0, 100.0) percentage = (math.floor(((100.0/number)*(10**decimals))+0.5)) / (10 ** decimals) last_percentage = 100.0 -(percentage * (number - 1)) return (percentage, last_percentage)