Person - Student

In [1]:
class Person:
    def __init__(self, name, age):
        self.name = name
        self.age = age 
    def walk(self):
        print('I am walking')
    def __str__(self):
        return 'name: {}\tage:{}'.format(self.name, self.age)
p1 = Person('Ahmed', 30)
print(p1)
name: Ahmed	age:30
In [4]:
class Student(Person):
    def __init__(self, std_id, name, age):
        self.std_id = std_id
        super().__init__(name, age)
    def study(self):
        print('I am studying')
        
    def __str__(self):
        return 'id: {}\t{}'.format(self.std_id, super().__str__())
        
s1 = Student('120191122', 'Ahmed', 20)
print(s1)
id: 120191122	name: Ahmed	age:20
In [ ]: