Skip to content

Commit 3376c7b

Browse files
authored
Add files via upload
Inheritence in python
1 parent 42e74a3 commit 3376c7b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Inheritence.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class person:
2+
def __init__(self,fname,lname):
3+
self.Firstname=fname
4+
self.Lastname=lname
5+
def print(self):
6+
print(self.Firstname)
7+
print(self.Lastname)
8+
print(self.contactNumber)
9+
def personContact(self,contact):
10+
self.contactNumber=contact
11+
class Student(person):
12+
def __init(self,sname,slname):
13+
self.studentFname=sname
14+
self.studentLname=slname
15+
super.__init__(self,sname,slname) #student class will run all the properties of parentclass
16+
Student1=Student("osama","Ayub")
17+
Student1.personContact(3314828005)
18+
Student1.print()

0 commit comments

Comments
 (0)