Next Index Previous

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


Father of Python Language

Guido-van-Rossum

Guido van Rossum

Born: January 31, 1956, Netherlands
Google+