• + 0 comments

    Python isolate rounding logic and use map()

    def rounding_function(grade):
        rounded = grade
        
        if grade >= 38:
            next_multiple_of_5 = ((grade // 5) + 1) * 5
            if next_multiple_of_5 - grade < 3:
                rounded = next_multiple_of_5
            
        return rounded
    
    def gradingStudents(grades):
        # Write your code here
        return map(rounding_function, grades