Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3847572

Browse files
Create Inheritance.py
1 parent 4cd3f7c commit 3847572

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

‎Class/Inheritance.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'''
2+
3+
Inheritance in python
4+
5+
Student consist of persons which represented below
6+
7+
'''
8+
9+
class Person:
10+
def __init__(self,fname,lname):
11+
self.fname=fname
12+
self.lname=lname
13+
14+
def print(self):
15+
print(fname,lname)
16+
17+
class Student(Person):
18+
def __init__(self,fname,lname,year):
19+
super().__init__(fname,lname)
20+
self.grad=year
21+
22+
def welcome(self):
23+
print("Hello",self.fname,self.fname,"you are graduated at ",self.grad)
24+
25+
26+
fun=Student("Nithin","U",2024)
27+
fun.welcome()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /