Calculate the CGPA and CGPA % of marks obtained by a Student in N subjects | Python3 program to calculate the CGPA and CGPA percentage of a student ; Variable to store the grades in every subject ; Variables to store CGPA and the sum of all the grades ; Computing the grades ; Computing the sum of grades ; Computing the CGPA ; Driver code
def CgpaCalc ( marks , n ) : NEW_LINE INDENT grade = [ 0 ] * n NEW_LINE Sum = 0 NEW_LINE for i in range ( n ) : NEW_LINE grade [ i ] = ( marks [ i ] / 10 ) NEW_LINE for i in range ( n ) : NEW_LINE Sum += grade [ i ] NEW_LINE cgpa = Sum / n NEW_LINE return cgpa NEW_LINE DEDENT n = 5 NEW_LINE marks = [ 90 , 80 , 70 , 80 , 90 ] NEW_LINE cgpa = CgpaCalc ( marks , n ) NEW_LINE print ( " CGPA ▁ = ▁ " , ' % .1f ' % cgpa ) NEW_LINE print ( " CGPA ▁ Percentage ▁ = ▁ " , ' % .2f ' % ( cgpa * 9.5 ) ) NEW_LINE