Apr-29-2020, 03:44 PM
yea i'm reading it now (i read the first article, now i'm in the class inheritance article),
and there's something that i see repeats itself always when defining a class:
in this code:
and there's something that i see repeats itself always when defining a class:
in this code:
class AnyEmployee(object): def __init__(self, grade, title, first, last, location, phone, pay): self.grade = grade self.title = title self.name = (last, first) self.location = location self.phone = phone self.pay = pay def contact_info(self): text = ', '.join(self.name) + ' (' if self.location: text += self.location + ', ' text += self.phone + ')' return text def weekly_pay(self, hours = 0): if self.grade == 'Manager': return round(self.pay / 52, 2) else: week = self.pay * hours if hours > 40: week += self.pay * 0.5 * (hours - 40) return weekhow do you call lines 4 to 9 ? (like, is there a term for it ?)