0% found this document useful (0 votes)
47 views

Implementing Classes and Instances: Output

This document defines an employee class with attributes like employee ID, name, salary, and department ID. It initializes two employee instances with different attributes and calls the displayemployee method to print out their details. It also prints the total number of employee instances created which is 2.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views

Implementing Classes and Instances: Output

This document defines an employee class with attributes like employee ID, name, salary, and department ID. It initializes two employee instances with different attributes and calls the displayemployee method to print out their details. It also prints the total number of employee instances created which is 2.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

7.

IMPLEMENTING CLASSES AND INSTANCES

class employee():

empcount = 0

def __init__(self, eid, name, salary, did):

self.eid = eid

self.name = name

self.salary = salary

self.did = did

employee.empcount += 1

def displayemployee(self):

print("eid:", self.eid, ",name:", self.name, ",salary:", self.salary, ",did:", self.did)

emp1 = employee(1, "zara", 2000, 10)

emp2 = employee(2, "meera", 4000, 20)

emp1.displayemployee()

emp2.displayemployee()

print("total employee %d" %employee.empcount)

OUTPUT:

eid: 1 ,name: zara ,salary: 2000 ,did: 10

eid: 2 ,name: meera ,salary: 4000 ,did: 20

total employee 2

You might also like