Python Examples
16. Python Class Constructor example.
class Employee:
name = ''
salary = ''
def __init__(self,n,s):
self.name = n
self.salary = s
def display(self):
print(self.name)
print(self.salary)
vishnu = Employee('Vishnu',50000)
vishnu.display()
Output :
Vishnu
50000
class Employee: name = '' salary = '' def __init__(self,n,s): self.name = n self.salary = s def display(self): print(self.name) print(self.salary) vishnu = Employee('Vishnu',50000) vishnu.display()Output :
Vishnu
50000
Father of Python Language