You are on page 1of 3

EXPERIMENT 6

Name/ROLL NO B1

Code
class Student:
def __init__(self, name, id):
self.name = name
self.id = id

def showDetails(self):
print(f"Student roll no. {self.id} is {self.name}")

class Programmer(Student):
def showLanguage(self):
print("He is Programmer and the language is Python")

e1 = Student("Chirag Davne", 3)
e1.showDetails()

e2 = Programmer("Shreyash Chavan", 2)
e2.showDetails()
e2.showLanguage()

e3 = Student("Bhavik patil", 19)


e3.showDetails()

e4 = Programmer("Ankush Taere", 13)


e4.showDetails()
e4.showLanguage()

e5 = Student("Pratemesh Tawde", 14)


e5.showDetails()

e6 = Student("Nadkishor Gupta ", 17)


e6.showDetails()

e7 = Student("Kaushik jadhav", 19)


e7.showDetails()
e2.showLanguage()

e8 = Student("Jyadeep Ghadshi", 6)
e8.showDetails()

1
EXPERIMENT 6
Name/ROLL NO B1

Output
Student roll no. 3 is Chirag Davne
Student roll no. 2 is Shreyash Chavan
He is Programmer and the language is Python
Student roll no. 19 is Bhavik patil
Student roll no. 13 is Ankush Taere
He is Programmer and the language is Python
Student roll no. 14 is Pratemesh Tawde
Student roll no. 17 is Nadkishor Gupta
Student roll no. 19 is Kaushik jadhav
He is Programmer and the language is Python
Student roll no. 6 is Jyadeep Ghadshi

Code
class A:
def feature1(self):
print('feature 1 working')
def feature2(self):
print('feature 2 working')
class B(A):
def feature3(self):
print('feature 3 working')
def feature4(self):
print('feature 4 working')
a1=A()
b1=B()
b1.feature1()
b1.feature2()
b1.feature3()
b1.feature4()

2
EXPERIMENT 6
Name/ROLL NO B1

Output
feature 1 working
feature 2 working
feature 3 working
feature 4 working

CONCLUSION : Hence we successfully implemented inheritance syntax in python.

You might also like