Students with maximum average score of three subjects | Function to find the list of students having maximum average score ; Variables to store maximum average score ; List to store names of students having maximum average score ; Traversing the file data ; finding average score of a student ; Clear the list and add name of student having current maximum average score in the list ; Printing the maximum average score and names of students having this maximum average score as per the order in the file . ; Driver Code ; Number of elements in string array
def getStudentsList ( file ) : NEW_LINE INDENT maxAvgScore = 0 NEW_LINE names = [ ] NEW_LINE for i in range ( 0 , len ( file ) , 4 ) : NEW_LINE INDENT avgScore = ( int ( file [ i + 1 ] ) + int ( file [ i + 2 ] ) + int ( file [ i + 3 ] ) ) // 3 NEW_LINE if avgScore > maxAvgScore : NEW_LINE INDENT maxAvgScore = avgScore NEW_LINE names . clear ( ) NEW_LINE names . append ( file [ i ] ) NEW_LINE DEDENT elif avgScore == maxAvgScore : NEW_LINE INDENT names . add ( file [ i ] ) NEW_LINE DEDENT DEDENT for i in range ( len ( names ) ) : NEW_LINE INDENT print ( names [ i ] , end = " ▁ " ) NEW_LINE DEDENT print ( maxAvgScore ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT file = [ " Shrikanth " , "20" , "30" , "10" , " Ram " , "100" , "50" , "10" ] NEW_LINE getStudentsList ( file ) NEW_LINE DEDENT