# Product.py # Static Methods for a Class Object page 57 # Create a Product Class and initialize 2 attrs name and price class Product: def __init__(self, name, price): self.name = name self.price = price # Static Methods # return belongs to the class, not the object # 'utility function' does not need to read the instance directly @staticmethod # utility function def apply_discount(price, discount): return price * (1 - discount) def update_price(self, discount): self.price = self.apply_discount(self.price, discount) # Output # Instance of the Class object product = Product("widget 1", 1000) # product is the INSTANCE of the object name in memory # Not going to use Product(), we are going to call static method for the utility function discounted_price = Product.apply_discount(1000, .10) print(f"Discounted Price: ${discounted_price:.2f}")