idiombench / Python /train /3.13 /dataclasses /modern_01.py
SwashBuckler001's picture
IdiomBench (part 6)
60f5111 verified
Raw History Blame Contribute Delete
248 Bytes
@dataclass
class InventoryItem:
'''Class for keeping track of an item in inventory.'''
name: str
unit_price: float
quantity_on_hand: int = 0
def total_cost(self) -> float:
return self.unit_price * self.quantity_on_hand