Suppose there is class of 10 students who have CGPA between 0-10. The university has decided to give the grace for those students those who have the CGPA between 4.5 to 4.9 to make it 5. Identify the students those have CGPA after adding the grace marks. Suppose students have its Roll_no & CGPA. Add the grace CGPA to the obtained CGPA of student by adding grace of 5 marks into the students through list comprehensions. Input Format- The input should contains an array of roll_no,and CGPA of the students. Constraints- CGPA must lies between 1.0 to 10.0 otherwise print "invalid input" Output Format- For each test case, display the roll_no and increased CGPA of those students only who lies between the obtained CGPA of 4.5-4.9
# Python3 program to calculate the CGPA
# and CGPA percentage of a student
def CgpaCalc(marks, n):
# Variable to store the grades in
# every subject
grade = [0] * n
# Variables to store CGPA and the
# sum of all the grades
Sum = 0
# Computing the grades
for i in range(n):
grade[i] = (marks[i] / 10)
# Computing the sum of grades
for i in range(n):
Sum += grade[i]
# Computing the CGPA
cgpa = Sum / n
return cgpa
# Driver code
n = 5
marks = [ 90, 80, 70, 80, 90 ]
cgpa = CgpaCalc(marks, n)
print("CGPA = ", '%.1f' % cgpa)
print("CGPA Percentage = ", '%.2f' % (cgpa * 9.5))
Comments
Leave a comment