Jul 3, 2024
__init__
method is used to initialize class attributes.def __init__(self):
self.price = 0
self.RAM = ''
self.processor = ''
self.price = 0
object.attribute = value
).HP.RAM = '16GB'
HP.processor = 'i7'
def display(self):
print(f'Price: {self.price}, RAM: {self.RAM}, Processor: {self.processor}')
HP = Laptop()
HP.RAM = '8GB'
HP.processor = 'i5'
HP.display()