The first line of the input contains an integer which represents the number of lines
The next n lines represent a space-separated list of the person and their marks in the four subjects
output should be name of the highest percentage?
for example
input:-
4 Manoj 30 40 45 63 Shivam 38 29 45 60 Siddheshwar 38 35 39 45 Ananya 45 29 30 51
Output:-
Manoj
code :-
details_vertical=[]
for ctr in range(4):
details_vertical.append(input().split())
for name,marks,marks,marks in zip(*details_vertical):
print(f"{name}")
Advertisement
Answer
Is this something that you’re looking for? Try it first, and ask questions.
There is room to improve it, but this is prob. most straightforward way.
details =[]
highest = 0
for i in range(4):
details = (input().split())
print(details) # just for debug, can comment out
total = sum(int(x) for x in details[1:]) # get this person's total
# change this print line to get average printout:
print(total / len(details[1:]) # it allows you have n+ scores flexibility - not assuming it's 4 only!
if total > highest: # processing along the way, so we don't have to save all the scores...
highest = total
best = details[0] # the person
print(best) # Manoj