-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGradingStudents.py
50 lines (35 loc) · 905 Bytes
/
GradingStudents.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/python3
import os
def findNext(item):
while item % 5 != 0:
item += 1
return item
#
# Complete the gradingStudents function below.
#
def gradingStudents(grades):
grades_ = []
for item in grades:
if item < 38:
grades_.append(item)
else:
if item % 5 == 0:
grades_.append(item)
else:
var = findNext(item)
if abs(var - item) < 3:
grades_.append(var)
else:
grades_.append(item)
return grades_
if __name__ == '__main__':
f = open(os.environ['OUTPUT_PATH'], 'w')
n = int(input())
grades = []
for _ in range(n):
grades_item = int(input())
grades.append(grades_item)
result = gradingStudents(grades)
f.write('\n'.join(map(str, result)))
f.write('\n')
f.close()