def __init__(self,name,ID,score):
self.name = name
self.ID = ID
self.score = score
def display(self):
print(self.name)
print(self.ID)
print(self.score)
def get_name(self):
return self.name
def get_score(self):
return self.score
def setup():
A = Student('Bung',10041,86)
B = Student('Ploy',20119,75)
C = Student('Toffy',20042,71)
D = Student('Game',20145,65)
E = Student('Mew',30078,79)
Total = [A,B,C,D,E]
print(find_grade(C))
print(count_grade('A',Total))
print()
show_allGtade(Total)
def find_grade(i):
char = ''
score = i.get_score()
if(score >= 80):
char = 'A'
elif(score >= 70 and score <= 79):
char = 'B'
elif(score >= 60 and score <= 69):
char = 'C'
elif(score >= 50 and score <= 59):
char = 'D'
else:
char = 'E'
return char
def count_grade(char , Total):
i = 0
number = 0
while(i < len(Total)):
score = Total[i].get_score()
if(char == 'A' and score >= 80):
number = number + 1
elif(char == 'B' and score >= 70 and score <= 79):
number = number + 1
elif(char == 'C' and score >= 60 and score <= 69):
number = number + 1
elif(char == 'D' and score >= 50 and score <= 59):
number = number + 1
elif(char == 'F' and score <= 49):
number = number + 1
i = i+1
return number
def show_allGtade(Total):
for i in Total:
i.display()
print(find_grade(i))
print()
setup()
ไม่มีความคิดเห็น:
แสดงความคิดเห็น