Source

dictionary_switches / code / TableDriven / grades.py

grade_scale = {
        90: "A",
        80: "B",
        70: "C",
        60: "D",
        00: "F"
        }

def find_max_of_scale( scale, value ):
    return max(filter( lambda x: value > x, scale.keys() ))

def get_grade( percentage ):
    return grade_scale[find_max_of_scale(grade_scale, percentage)]