We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
classStudent(Person):# Class Constructor# # Parameters:# firstName - A string denoting the Person's first name.# lastName - A string denoting the Person's last name.# id - An integer denoting the Person's ID number.# scores - An array of integers denoting the Person's test scores.## Write your constructor heredef__init__(self,firstName,lastName,idNumber,scores):Person.__init__(self,firstName,lastName,idNumber)self.scores=scores
# Function Name: calculate
# Return: A character denoting the grade.
#
# Write your function here
def calculate(self):
sum = 0
for i in range(len(self.scores)):
sum = sum + self.scores[i]
avg = sum/len(self.scores)
if ((90<=avg) and (avg<=100)):
return str("O")
elif ((80<=avg) and (avg<90)):
return str("E")
elif ((70<=avg) and (avg<80)):
return str("A")
elif ((55<=avg) and (avg<70)):
return str("P")
elif ((40<=avg) and (avg<55)):
return str("D")
else:
return str("T")
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Inheritance
You are viewing a single comment's thread. Return to all comments →