I wrote this in Python with the assumption that the input of the function will all be integers between 0 and 100.
def grade(*grades): grade_range = [(90, 'A'),(80, 'B'),(70, 'C'),(60, 'D')] mean = 0 for _, score in enumerate(grades): mean += score mean = int(mean / len(grades)) polarity = "+" if mean % 10 >= 5 else "-" for grade in grade_range: if mean >= grade[0]: return grade[1] + polarity return "F" + polarity
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I wrote this in Python with the assumption that the input of the function will all be integers between 0 and 100.