How to instantiate object in python?

Published: 01 January 1970
on channel: PythonEnthusiasts
8
0

#PYTHON PROGRAM TO DEFINE A CLASS AND INSTANTIATE AN OBJECT
class Employee:
def __init__(self, name, place):
self.name = name
self.place = place

def employee_Details(self):
print("Hello, my name is", self.name,"and I am from :",self.place)

#instantitaite the object
emp1 = Employee("Ram","Pune")
emp1.employee_Details()


#instantitaite the object
emp2 = Employee("Sam","Mumbai")
emp2.employee_Details()

OUTPUT:
Hello, my name is Ram and I am from : Pune
Hello, my name is Sam and I am from : Mumbai