Skip to content

Commit 51746fb

Browse files
authored
Create Inheritance.py
1 parent 4dd07cf commit 51746fb

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class employee:
2+
company = "Microsoft"
3+
language = "Python"
4+
5+
def __init__(self, name):
6+
self.name = name
7+
8+
def info(self):
9+
print(f"The name of the employee is {self.name}. He is in the company: {self.company}, He uses the language: {self.language}")
10+
11+
class programmer(employee): # Inherits from employee
12+
company = "Google" # Overrides class variable
13+
language = "Java"
14+
15+
bob = employee("Bob")
16+
bob.info()
17+
18+
alice = programmer("Alice")
19+
alice.info()

0 commit comments

Comments
 (0)