inheritance in python

technical talkiess
0

 Inheritance in the python:- 

class Student:

    no_of_leaves = 89


    def __init__(self,name,age,salary):

        self.name = name

        self.age = age

        self.salary = salary


    def printDetails(self):

        print(f"The name of the student is {self.name} and age of the student {self.age} and salary of the student is {self.salary}")



# inheritance of the student class

# This is the single inheritance in the python

class Person(Student):

    no_of_holidays = 89


    def __init__(self, name, age, salary,languages):

        self.name = name

        self.age = age

        self.salary = salary

        self.languages = languages


    def printPerson(self):

         print(f"The Person name of the student is {self.name} and age of the student {self.age} and salary of the student is {self.salary}")




vishal = Student("vishal",250,5000)

lakhan = Person("lakhan",250,5000,["python","test","Dummy"])

print(lakhan.printDetails())

Post a Comment

0Comments

Thanks you for commenting your questions. I will see question and respond you.

Post a Comment (0)