In this example we will show how to create a class that inherits the functionality from another class in Python.
Source Code
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
def print_person_info(self):
print('name:', self.name, 'age:', self.age)
class Student(Person):
pass
s = Student('John', 15) # create an object
s.print_person_info() # execute the print_person_info method
Output:
name: John age: 15