Skip to content

Commit 9702948

Browse files
authored
Add files via upload
1 parent 350d3c5 commit 9702948

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
class employee:
2+
company = "works in Microsoft"
3+
4+
def __init__(self):
5+
print("Employee class constructor.")
6+
7+
class coder(employee): # Inherits from employee
8+
language = "Python"
9+
company = "Works in Google" # Overriding the company attribute
10+
def __init__(self):
11+
print("Coder class constructor.")
12+
13+
def showlanguage(self):
14+
print(f"The language used is {self.language}.")
15+
16+
class manager(coder):
17+
name = "Rani" # Inherits from coder
18+
def __init__(self):
19+
print("Manager class constructor.")
20+
def showname(self):
21+
print(f"The name of the manager is {self.name}.")
22+
23+
karan = employee() # This will call the employee constructor
24+
print(karan.company)
25+
#---------------------
26+
rohit = coder()
27+
print(rohit.company)
28+
rohit.showlanguage()
29+
#-----------------------
30+
rani = manager()
31+
print(rani.company)
32+
rani.showlanguage()
33+
rani.showname() # This will call the showname method of manager
34+
35+
#----------Use of super() to call parent class methods----------

0 commit comments

Comments
 (0)