forked from fenyx-it-academy/Class4-PythonModule-Week5
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWeek 5-Odev_3.py
More file actions
42 lines (34 loc) · 1.51 KB
/
Week 5-Odev_3.py
File metadata and controls
42 lines (34 loc) · 1.51 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
class Product:
def __init__(self, product_id, product_name, product_purchase_price, product_sale_price):
self.product_id = str(product_id)
self.product_name = str(product_name)
self.product_purchase_price = float(product_purchase_price)
self.product_sale_price = float(product_sale_price)
def set_remarks(self):
self.price_margin = self.product_sale_price - self.product_purchase_price
if self.price_margin < 0:
print('Your Loss.....={}'.format(self.price_margin))
elif self.price_margin > 0:
print('Your profit.....={}'.format(self.price_margin))
elif self.price_margin == 0:
print('Your p.....={}'.format(self.price_margin))
def set_details(self):
self.product_id = str(input("Enter product id: "))
self.product_name = str(input("Enter product name: "))
self.product_purchase_price = float(input("Enter product purchase price: "))
self.product_sale_price = float(input("Enter product sale price: "))
self.product_margin = self.set_remarks()
def get_details(self):
all_result = """
Product id: {}
Product name: {}
Product purchase price: {}
Product sale price: {}
Product margin: {}
""".format(self.product_id, self.product_name, self.product_purchase_price, self.product_sale_price,
self.product_margin)
return all_result
p = Product(111, "x", 10, 12)
p.set_details()
p.set_remarks()
print(p.get_details())