-
Notifications
You must be signed in to change notification settings - Fork 94
/
Copy pathE2-8.py
25 lines (20 loc) · 750 Bytes
/
E2-8.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Copyright (C) Deepali Srivastava - All Rights Reserved
# This code is part of Python course available on CourseGalaxy.com
class Product():
def __init__(self, id, marked_price, discount):
self.id = id
self.marked_price = marked_price
self.discount = discount
@property
def selling_price(self):
return self.marked_price - 0.01 * self.discount * self.marked_price
def display(self):
print(self.id, self.marked_price, self.discount)
p1 = Product('A234', 100, 5)
p2 = Product('X879', 400, 6)
p3 = Product('B987', 990, 4)
p4 = Product('H456', 800, 6)
print(p1.id, p1.selling_price)
print(p2.id, p2.selling_price)
print(p3.id, p3.selling_price)
print(p4.id, p4.selling_price)