-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmob_phn.py
More file actions
28 lines (22 loc) · 799 Bytes
/
Copy pathmob_phn.py
File metadata and controls
28 lines (22 loc) · 799 Bytes
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
class Mobile:
def __init__(self, brand, model, price):
self.brand = brand
self.model = model
self.price = price
def apply_discount(self, discount_amount):
if discount_amount <= self.price:
self.price -= discount_amount
print(f"Discount of ₹{discount_amount} applied successfully.")
else:
print("Discount amount cannot be greater than price!")
def display_mobile(self):
print("\n--- Mobile Details ---")
print(f"Brand: {self.brand}")
print(f"Model: {self.model}")
print(f"Price: ₹{self.price}")
# Creating object
mobile1 = Mobile("Samsung", "Galaxy S23", 75000)
# Calling methods
mobile1.display_mobile()
mobile1.apply_discount(5000)
mobile1.display_mobile()