Simple Inheritance implementation in Python


In this article, we have demonstrated a simple Python Program which implements Inheritance.

Inheritance example in Python


class Person: def __init__(self,first,last): self.first_name = first self.last_name = last def name(self): return self.first_name + " " + self.last_name class Employee(Person): def __init__(self,first,last,age): Person.__init__(self,first,last) self.age = age def GetEmployeeDetails(self): return "Name:" + + " Age:" + self.age if __name__ == '__main__': first = raw_input("Enter your first name") last = raw_input("Enter your last name") age = raw_input("Enter your age") x = Person(first,last) y = Employee(first,last,age) print( print(y.GetEmployeeDetails())


Enter your first name baburao Enter your last name apte Enter your age20 baburao apte Name: baburao apte Age:20

Struggling to Understand Algorithm and Flowchart? Try our Notes

Want to Test Your Knowledge on Algorithm and Flowchart?

Other Notes you might be Interested in:


Recommended Deals End in

Top Java Interview Questions PDF Guide with 30+ Pages

Online Games
Play 2048 Game Online and Relax.
Play 2048 Game Online

Quiz to Test Your Skills
Search Tags