Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 KB | None | 0 0
  1. def calc(scores):
  2.     total = 0
  3.     for i in scores:
  4.         total += i
  5.     avg = total / 3
  6.     return total, round(avg, 2)
  7.  
  8. score = [[76, 73, 85], [88, 84, 76], [92, 82, 92], [82, 91, 85], [72, 74, 73]]
  9. highest = 0
  10. highest_avg = 0
  11. class_total = 0
  12. _class_total = 0
  13. for i in range(len(score)):
  14.     print('student', i+1)
  15.     total, avg = calc(score[i])
  16.     class_total += avg
  17.     _class_total += total
  18.     if avg > highest_avg:
  19.         highest = i + 1
  20.         highest_avg = avg
  21.  
  22.     for j in range(len(score[i])):
  23.         print(' {}: {}'.format(j+1, score[i][j]))
  24.  
  25.     print(' sum: ', total)
  26.     print(' avg: ', avg)
  27. print('total: {}, avg: {}'.format(_class_total, round(class_total/5, 2)))
  28. print('highest avg: student {}: {}'.format(highest, highest_avg))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement