def __init__(self,name,id,score):
self.name = name
self.id = id
self.score = score
def display(self):
print('Name :',self.name)
print('ID :',self.id)
print('Score :',self.score)
def get_score(self):
return self.score
def setup():
a = Student('Ant',1,80)
b = Student('Bird',2,75)
c = Student('Cat',3,59)
d = Student('Dog',4,15)
e = Student('Elephant',5,62)
data = [a,b,c,d,e]
show_allgrade(data)
def find_grade(data):
if(80 <= data.get_score()):
return 'A'
elif(70 <= data.get_score()):
return 'B'
elif(60 <= data.get_score()):
return 'C'
elif(50 <= data.get_score()):
return 'D'
else:
return 'F'
def count_grade(c,data):
i=0
count=0
while(i < len(data)):
if(find_grade(data[i]) == c):
count+=1
i+=1
return count
def show_allgrade(data):
i=0
while(i < len(data)):
data[i].display()
print('Grade :',find_grade(data[i]))
print()
i+=1
setup()
No comments:
Post a Comment