Answer to Question #174552 in Python for Fatine

Question #174552

Write a python program that: 

  • • asks the user for the number of students and subjects to be managed. 
  • • For each student, asks the user for the mark obtained in all subjects 
  • • Calculates the final score of each student considering that all subjects have a coefficient equal to 1. 
  • • Displays the best final score (maximum) and the student who obtained it. 

Note: 

- Students are referred to using an ID (automatically incremented, starting from 1). 

1
Expert's answer
2021-03-23T04:44:04-0400
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}")

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