Classes

Everything in python is a class. A class is a data type.

Let’s define a person. A person has a name and an age. For now, this is all we need.

class Person():
	def __init__(self, name="Smith", age=18):
		self.name = name
		self.age = age
	
	def happy_birthday(self):
		self.age = self.age + 1
		print("Happy birthday "+ self.name)


p = Person("John")
print(p.name) # John
print(p.age) # 18

p.happy_birthday() # this will return  'Happy birthday John'
p.happy_birthday() # this will return  'Happy birthday John'
print(p.age) # 20

__init__ is a special function called constructor. It helps us to initialize the