class Product:
def __init__(self, name, model):
self.name = name
self.model = model
def printDetails(self):
print("Name:", self.name)
print("Model:", self.model)
class Price:
def __init__(self, price, discountPrecent):
self.price = price
self.discount = discountPrecent
def calculatedPrice(self):
if self.discount > 80 or self.discount <= 0:
return self.price
else:
return self.price - (self.price * self.discount) / 100
my_product = Product("Sonic Wireless Headphone", "SWH-30G21")
my_product.printDetails()
my_product_price = my_product.Price(99.99, 10)
print("Actual price: ", my_product_price.price)
print("Discount (%): ", my_product_price.discount)
print("Calculated PRice: ", my_product_price.calculatedPrice())
PythonOutput:
Name: Sonic Wireless Headphone
Model: SWH-30G21
Actual price: 99.99
Discount (%): 10
Calculated PRice: 89.991
Plaintext