-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsuper.py
More file actions
29 lines (24 loc) · 821 Bytes
/
Copy pathsuper.py
File metadata and controls
29 lines (24 loc) · 821 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
# super keyword in python is used to represent the parent class
# class danish:
# def dana(self):
# print("danish")
# class kartik(danish):
# def new(self):
# print("this is the super class methods")
# # super().dana() #
# a=kartik()
# a.dana() # it will first search the dana() in present class if not preesent then it will find it in super class
# using super for constructor
class Employee:
def __init__(self, name, id):
self.name = name
self.id = id
class Programmer(Employee):
def __init__(self, name, id, lang):
super().__init__( name, id) # it will directly get the attributes of super class constructor
self.lang = lang
rohan = Employee("Rohan Das", "420")
harry = Programmer("Harry", "2345", "Python")
print(harry.name)
print(harry.id)
print(harry.lang)