Sunday, August 20, 2017

Rounding Marks

In a college, each student receives marks M in any of the subjects in the range from 0 to 100.
- If the difference between the marks and the next multiple of 5 is less than 3, then round the marks up to the next multiple of 5.
- If the difference between the marks and the next multiple of 5 is more than or equal to 3, then leave the marks as it is.
- If the marks obtained is less than or equal to 37, then leave the marks as it is.

Input Format:
The first line will contain the value of N which represents the count of the test cases.
Next N lines will contain the marks from M(1) to M(N)

Output Format:
N lines containing the rounded marks value, one line each for the marks from M(1) to M(N)

Constraints:
2 <= N <= 100

Example Input/Output 1:
Input:
4
83
57
48
33
Output:
85
57
50
33

Solution:
n = int(input())
for _ in range(n):
    a = int(input())
    if ((a//5)+1)*5 - a < 3 and a>37:
        print(((a//5)+1)*5)
    else:
        print(a)
Share: