Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. class Person:
  2. def __init__(self, first_name, last_name, id_number):
  3. self.first_name = first_name
  4. self.last_name = last_name
  5. self.id_number = id_number
  6.  
  7. def print_person(self):
  8. print("Name:", self.last_name + ",", self.first_name)
  9. print("ID:", self.id_number)
  10.  
  11.  
  12. class Student(Person):
  13. def __init__(self, first_name, last_name, id_number, test_scores):
  14. super().__init__(first_name, last_name, id_number)
  15. self.test_scores = test_scores
  16.  
  17. def calculate(self):
  18. total = 0
  19. for test_score in self.test_scores:
  20. total += test_score
  21.  
  22. avg = total / len(self.test_scores)
  23.  
  24. if 90 <= avg <= 100:
  25. return 'O'
  26. if 80 <= avg < 90:
  27. return 'E'
  28. if 70 <= avg < 80:
  29. return 'A'
  30. if 55 <= avg < 70:
  31. return 'P'
  32. if 40 <= avg < 55:
  33. return 'D'
  34. return 'T'
  35.  
  36.  
  37. line = input().split()
  38. first_name = line[0]
  39. last_name = line[1]
  40. id_num = line[2]
  41. num_scores = int(input())
  42. scores = list(map(int, input().split()))
  43. s = Student(first_name, last_name, id_num, scores)
  44. s.print_person()
  45. print("Grade:", s.calculate())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement