Class and Object – OOP Python

Create Class

class Laptop:
	def __init__(self, name, processor, hdd, ram):
		self.name = name
		self.processor = processor
		self.hdd = hdd
		self.ram = ram
	def details(self):
		print('The details of the laptop are:')
		print('Name         :', self.name)
		print('Processor    :', self.processor)
		print('HDD Capacity :', self.hdd)
		print('RAM          :', self.ram)

OOP Python – Object

laptop1 = Laptop('Dell Alienware', 'Intel Core i7', 512, 8)
print(laptop1.name)
print(laptop1.processor)
laptop1.details()

#output
 	Dell Alienware
	Intel Core i7
	The details of the laptop are:
	Name         : Dell Alienware
	Processor    : Intel Core i7
	HDD Capacity : 512
	RAM          : 8