Class variables vs Instance variables Class Methods vs Instance Methods Instance Method is called ON an object using the "dot" notation e.g. xs1 = [1,2,3] xs1.append(10) xs2 = ["a","b"] xs2.append("c") Class Methods d1 = Date(1,1,2024) d2 = Date(10,2,2024) d1.today() # not a proper way to call this method td = Date.today() keep count of how many Date objects are constructed class Date: count = 0 # class variables def __init__(self, m, d, y): self.month = m # instance variables self.day = d self.year = y Date.count = Date.count + 1 @classmethod def count_objects(cls): return Date.count from datetime import date @classmethod def today(cls): today = date.today() year = int(str(today)[0:4]) month = int(str(today)[5:7]) day = int(str(today)[8:]) return Date(month,day,year) d = self.day #m = 1 + (self.month-3)%12 if self.month == 1: m = 11 elif self.month == 2: m = 12 else: m = self.month - 2 #Y = ??? if m in [11,12]: Y = self.year - 1 else: Y = self.year c = Y // 100 y = Y % 100 w = (d + math.floor(2.6*m-0.2)......)%7 if self.month in [3,4...12]: m = (self.month-2) elif self.month == 1: m = 11 else: m = 12 m = ??? days_between: self d ndaysSelf = 365*self.year ndaysD = 365*d.year diff = ndaysSelf - ndaysD ....adjust for months/days nleap = numLeapYears(self,d) return abs(diff+nleap) +10 -8