def init

Solutions on MaxInterview for def init by the best coders in the world

showing results for - "def init "
Marlene
19 Jun 2018
1#!/usr/bin/python
2
3class Employee:
4   'Common base class for all employees'
5   empCount = 0
6
7   def __init__(self, name, salary):
8      self.name = name
9      self.salary = salary
10      Employee.empCount += 1
11   
12   def displayCount(self):
13     print "Total Employee %d" % Employee.empCount
14
15   def displayEmployee(self):
16      print "Name : ", self.name,  ", Salary: ", self.salary
17
18"This would create first object of Employee class"
19emp1 = Employee("Zara", 2000)
20"This would create second object of Employee class"
21emp2 = Employee("Manni", 5000)
22emp1.displayEmployee()
23emp2.displayEmployee()
24print "Total Employee %d" % Employee.empCount