Answer to Question #266064 in Python for Rushikesh

Question #266064

 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


1
Expert's answer
2021-11-15T00:20:08-0500
# 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))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS