I request you read last post before Inheritance. Lets kept going with banker analogy
- After Filling the form.
- Now, how much money do you want to deposit.
class BankForm: def __init__(self,Name,DOB,AdhaarNo,PAN): self.Name=Name self.DOB=DOB self.AdhaarNo=AdhaarNo self.PAN=PAN def full_name(self): return f"{self.Name} {self.DOB} {self.AdhaarNo} {self.PAN} {self.deposit}" class Deposit(BankForm): def __init__(self,Name,DOB,AdhaarNo,PAN,deposit): super().__init__(Name,DOB,AdhaarNo,PAN) self.deposit=deposit Rohan=Deposit("Rohan","12-09-2025","xxxx8907","KB1234","2000") print(Rohan.full_name())
- Now I have created Deposit class in this I have data of people how much money they hold.
- And I have inherited the class BankForm Where they information about account holder.
- If we can inherit the class so definitely we can inherit there attribute. By using 'super'.
- 'super' it is just like I want to inherit attribute of my parent.
- And we can create new attribute of our own like deposit, also inherit there function which is full_name()
- But if you notice correctly I have played around and add deposit in full function and it return the deposit value also.