Answer to Question #174493 in Python for Fatine Ait Touda

Question #174493

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. 
1
Expert's answer
2021-03-22T17:00:30-0400
students = int(input('Number of students: '))
subjects = int(input('Number of subjects: '))
name = []
score = []

for i in range(students):
    name.append(input('Name: '))
    [score.append(int(input('Score ' + str(j+1) + ' subject: '))) for j in range(subjects)]

def sum_sub(score, num):
    s = [score[i:i + num] for i in range(0, len(score), num)]
    return [sum(j)/num for j in s]

names = name
scores = sum_sub(score, subjects)

total = [max(scores), names[scores.index(max(scores))]]

print('Best final score and student: {0}, {1}'.format(total[0], total[1]))

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