def aggregate_scores(scores):
 total_correct_graded = float_sum((score.earned for score in scores if score.graded))
 total_possible_graded = float_sum((score.possible for score in scores if score.graded))
 any_attempted_graded = any((score.attempted for score in scores if score.graded))
 total_correct = float_sum((score.earned for score in scores))
 total_possible = float_sum((score.possible for score in scores))
 any_attempted = any((score.attempted for score in scores))
 all_total = AggregatedScore(total_correct, total_possible, False, any_attempted)
 graded_total = AggregatedScore(total_correct_graded, total_possible_graded, True, any_attempted_graded)
 return (all_total, graded_total)

def aggregate_scores ( scores ) : total_correct_graded = float_sum ( ( score . earned for score in scores if score . graded ) ) total_possible_graded = float_sum ( ( score . possible for score in scores if score . graded ) ) any_attempted_graded = any ( ( score . attempted for score in scores if score . graded ) ) total_correct = float_sum ( ( score . earned for score in scores ) ) total_possible = float_sum ( ( score . possible for score in scores ) ) any_attempted = any ( ( score . attempted for score in scores ) ) all_total = AggregatedScore ( total_correct , total_possible , False , any_attempted ) graded_total = AggregatedScore ( total_correct_graded , total_possible_graded , True , any_attempted_graded ) return ( all_total , graded_total )
scores: a list of scorebase objects returns: a tuple .