forked from hariom20singh/python-learning-codes
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoops.py
More file actions
Latest commit
37 lines (28 loc) · 996 Bytes
/
Copy pathoops.py
File metadata and controls
37 lines (28 loc) · 996 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
classPerson(object):
# __init__ is known as the constructor
def__init__(self, name, idnumber):
self.name=name
self.idnumber=idnumber
defdisplay(self):
print(self.name)
print(self.idnumber)
defdetails(self):
print("My name is {}".format(self.name))
print("IdNumber: {}".format(self.idnumber))
# child class
classEmployee(Person):
def__init__(self, name, idnumber, salary, post):
self.salary=salary
self.post=post
# invoking the __init__ of the parent class
Person.__init__(self, name, idnumber)
defdetails(self):
print("My name is {}".format(self.name))
print("IdNumber: {}".format(self.idnumber))
print("Post: {}".format(self.post))
# creation of an object variable or an instance
a=Employee('Rahul', 886012, 200000, "Intern")
# calling a function of the class Person using
# its instance
a.display()
a.details()