题解 | #多部门的打工人#
多部门的打工人
https://www.nowcoder.com/practice/e704f2c5c30c4aa0b1de9e71bc584fb3
#考点,1:子类继承父类的方法,2:调用子类调用父类属性的方法 class Nowcoder(object): def __init__(self,name,ID,num): self.name = name self.ID = ID self.num = num def printInformation(self): print(f"{self.name}'s ID is {self.ID}, and his or her number of signing in is {self.num}.") class IT(Nowcoder): def __init__(self, name, ID, num, language): super().__init__(name, ID, num) self.language = language def printInformation(self): return super().printInformation(),self.language class Designer(Nowcoder): def __init__(self, name, ID, num, color): super().__init__(name, ID, num) self.color = color def printInformation(self): return super().printInformation(),self.color info1 = input().split() info2 = input().split() N_n = IT(info1[0],info1[1],info1[2],info1[3]) N_n.printInformation() print(N_n.language) N_m = Designer(info2[0],info2[1],info2[2],info2[3]) N_m.printInformation() print(N_m.color)