According to the question, If the difference between the grade and the next multiple of 5 is less than 3, round grade up to the next multiple of 5 . If the value of grade is less than 38, no rounding occurs as the result will still be a failing grade.
Here's my solution for it,
def gradingStudents(grades):
for i in grades:
if (5 * round(1 + i/5) - i) < 3 and i>= 38:
print (5 * round(1 + i/5))
else:
print (i)
grades_count = int(input().strip())
grades = []
for p in range(grades_count):
g = int(input(''))
grades.append(g)
result = gradingStudents(grades)
However, on examining the output I noticed that the if condition is not working as the output generates the same grade as the input.