Physics, asked by divishagora8269, 11 months ago

Top Scoring Student

Names of N students and the marks scored by them in Maths, Physics and Chemistry are passed as the input. The program must print the name of the student who has scored the maximum marks in these three subjects. (Assume only one student will be the top scorer).


Input Format:

The first line denotes the value of N.

Next N lines will contain the name of the student and the marks in three subjects separated by colon.


Output Format:

The first line contains the name of the students with the highest marks.


Boundary Conditions:

2 <= N <= 50

The length of the names will be from 3 to 100.

The value of the marks will be from 0 to 100.


Example Input/Output 1:

Input:

4

Sasikumar:50:60:70

Arun:60:40:90

Manoj:50:50:60

Rekha:60:35:45


Output:

Arun

Answers

Answered by argironman
11

Answer:

n=int(input())

student={}

for i in range(n):      

   student[i]={}      

   t=input().split(':')      

   student[i]['Name']=t[0]

   student[i]['M1']=int(t[1])

   student[i]['M2']=int(t[2])

   student[i]['M3']=int(t[3])

   student[i]['Total']=sum([int(j) for j in t[1:]])  

#Use print(student) here to know how above loop stored values

temp_high={'Name':student[0]['Name'],'Total':student[0]['Total']}  

#Use print(temp_high) to understand what happened above

for i in student:

   if student[i]['Total']>=temp_high['Total']:

temp_high['Name']=student[i]['Name']

temp_high['Total']=student[i]['Total']

print(temp_high['Name'])

Explanation:

I know that op asked the question a year before and would have probably got an answer but i added an answer anyway for those who can't get the answer.The program is in python 3.

Answered by Sanav1106
1

The HTML code for the given input and output format along with boundary conditions shall be:

n=int(input())

student={}

for i in range(n):      

  student[i]={}      

  t=input().split(':')      

  student[i]['Name']=t[0]

  student[i]['M1']=int(t[1])

  student[i]['M2']=int(t[2])

  student[i]['M3']=int(t[3])

  student[i]['Total']=sum([int(j) for j in t[1:]])  

#Use print(student) here to know how above loop stored values

temp_high={'Name':student[0]['Name'],'Total':student[0]['Total']}  

#Use print(temp_high) to understand what happened above

for i in student:

  if student[i]['Total']>=temp_high['Total']:

temp_high['Name']=student[i]['Name']

temp_high['Total']=student[i]['Total']

print(temp_high['Name'])

#SPJ2

Similar questions