-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path12 th day: Inheritance.
54 lines (45 loc) · 1.18 KB
/
12 th day: Inheritance.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
class Person:
def __init__(self, firstName, lastName, idNumber):
self.firstName = firstName
self.lastName = lastName
self.idNumber = idNumber
def printPerson(self):
print("Name:", self.lastName + ",", self.firstName)
print("ID:", self.idNumber)
class Student(Person):
def __init__(self,firstName,lastName,idNum,scores):
Person.__init__(self, firstName, lastName, idNum)
self.scores = scores
def calculate(self):
a = sum(scores)
avg = a/(len(scores))
if avg>=90 and avg<=100:
return 'O'
if avg>=80 and avg<90:
return 'E'
if avg>=70 and avg<80:
return 'A'
if avg>=55 and avg<70:
return 'P'
if avg>=40 and avg<55:
return 'D'
if avg<40:
return 'T'
line = input().split()
firstName = line[0]
lastName = line[1]
idNum = line[2]
numScores = int(input()) # not needed for Python
scores = list( map(int, input().split()) )
s = Student(firstName, lastName, idNum, scores)
s.printPerson()
print("Grade:", s.calculate())
'''Sample Input
Heraldo Memelli 8135627
2
100 80
Sample Output
Name: Memelli, Heraldo
ID: 8135627
Grade: O
'''