-
Notifications
You must be signed in to change notification settings - Fork 8
/
Grading Students.py
123 lines (72 loc) · 2.92 KB
/
Grading Students.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# HackerLand University has the following grading policy:
# Every student receives a in the inclusive range from to .
# Any less than is a failing grade.
# Sam is a professor at the university and likes to round each student's according to these rules:
# If the difference between the and the next multiple of is less than , round up to the next multiple of .
# If the value of is less than , no rounding occurs as the result will still be a failing grade.
# For example, will be rounded to but will not be rounded because the rounding would result in a number that is less than .
# Given the initial value of for each of Sam's students, write code to automate the rounding process.
# Function Description
# Complete the function gradingStudents in the editor below. It should return an integer array consisting of rounded grades.
# gradingStudents has the following parameter(s):
# grades: an array of integers representing grades before rounding
# Input Format
# The first line contains a single integer, , the number of students.
# Each line of the subsequent lines contains a single integer, , denoting student 's grade.
# Constraints
# Output Format
# For each , print the rounded grade on a new line.
# Sample Input 0
# 4
# 73
# 67
# 38
# 33
# Sample Output 0
# 75
# 67
# 40
# 33
# Explanation 0
# image
# Student received a , and the next multiple of from is . Since , the student's grade is rounded to .
# Student received a , and the next multiple of from is . Since , the grade will not be modified and the student's final grade is .
# Student received a , and the next multiple of from is . Since , the student's grade will be rounded to .
# Student received a grade below , so the grade will not be modified and the student's final grade is .
#!/bin/python3
import math
import os
import random
import re
import sys
#
# Complete the 'gradingStudents' function below.
#
# The function is expected to return an INTEGER_ARRAY.
# The function accepts INTEGER_ARRAY grades as parameter.
#
def gradingStudents(grades):
list1 = []
for i in range(0,len(grades)):
if(grades[i] < 38):
# list1.append(grades[i])
grades[i] = grades[i]
else:
if((grades[i]+1)%5 == 0):
grades[i] = grades[i]+1
elif((grades[i]+2)%5 == 0):
grades[i] = grades[i]+2
else:
grades[i] = grades[i]
return(grades)
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
grades_count = int(input().strip())
grades = []
for _ in range(grades_count):
grades_item = int(input().strip())
grades.append(grades_item)
result = gradingStudents(grades)
fptr.write('\n'.join(map(str, result)))
fptr.write('\n')
fptr.close()