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.
classPerson:def__init__(self,firstName,lastName,idNumber):self.firstName=firstNameself.lastName=lastNameself.idNumber=idNumberdefprintPerson(self):print("Name:",self.lastName+",",self.firstName)print("ID:",self.idNumber)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):super().__init__(firstName,lastName,idNumber)self.scores=scoresdefcalculate(self):wynik2=sum(self.scores)/len(self.scores)if90<=wynik2andwynik2<=100:return"O"elif80<=wynik2andwynik2<90:return"E"elif70<=wynik2andwynik2<80:return"A"elif55<=wynik2andwynik2<70:return"P"elif40<=wynik2andwynik2<55:return"D"elifwynik2<40:return"T"line=input().split()firstName=line[0]lastName=line[1]idNum=line[2]numScores=int(input())#notneededforPythonscores=list(map(int,input().split()))s=Student(firstName,lastName,idNum,scores)s.printPerson()print("Grade:",s.calculate())
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 12: Inheritance
You are viewing a single comment's thread. Return to all comments →
****Python code*