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.
Day 12: Inheritance
Day 12: Inheritance
Sort by
recency
|
1176 Discussions
|
Please Login in order to post a comment
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, idNumber, scores): self.firstName = firstName self.lastName = lastName self.idNumber = idNumber self.scores = scores
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())
Java Solution:
any advice on my code? can you make it better or even shorter?
Student class implementation with Python:
javascript