Write a python program that:
Note:
- Students are referred to using an ID (automatically incremented, starting from 1).
n_students = int(input('Enter number of students: '))
n_subjects = int(input('Enter number of subjects: '))
max_final_score = 0
max_final_score_students = []
print('Enter obtained marks separated by spaces:')
for student_id in range(1, n_students+1):
final_score = 0
marks = list(input(f'student {student_id}: ').split())
for mark in marks:
final_score += int(mark)
if final_score == max_final_score:
max_final_score_students.append(student_id)
if final_score > max_final_score:
max_final_score_students = [student_id]
max_final_score = final_score
best_students = ", ".join(map(str,max_final_score_students))
students = "students" if len(max_final_score_students) > 1 else "student"
print(f"Best final score is {max_final_score} obtained by {students} with id {best_students}")
Comments
Leave a comment