Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Item:
- def __init__(self, name: str, price: float, quantity=0):
- assert price >= 0, f"Price {price} is not greater than zero!"
- assert quantity >= 0, f"Quantity {quantity} is not greater than zero!"
- self.name = name
- self.price = price
- self.quantity = quantity
- def calculateTotalPrice(self):
- return self.price * self.quantity
- item1 = Item("Phone", 100, 1)
- item2 = Item("Laptop", 1000, 3)
- print(item1.calculateTotalPrice())
- print(item2.calculateTotalPrice())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement