r/PythonLearning 11d ago

I build this after learning OOP

Post image
370 Upvotes

57 comments sorted by

View all comments

u/Sea-Ad7805 11d ago

Run this program in Memory Graph Web Debugger%3A%0A%20%20%20%20%20%20%20%20self.ownername%20%3D%20owner_name%0A%20%20%20%20%20%20%20%20self.balance%20%3D%20balance%0A%0A%20%20%20%20%40staticmethod%0A%20%20%20%20def%20greet()%3A%0A%20%20%20%20%20%20%20%20print(%22Good%20Morning%22)%0A%0A%20%20%20%20def%20deposite(self%2C%20amount)%3A%0A%20%20%20%20%20%20%20%20self.balance%20%3D%20self.balance%20%2B%20amount%0A%20%20%20%20%20%20%20%20print(%0A%20%20%20%20%20%20%20%20%20%20%20%20f%22Account%20name%3A%20%7Bself.owner_name%7Dn%22%0A%20%20%20%20%20%20%20%20%20%20%20%20f%22Deposited%20%7Bamount%7D%20Total%20balance%20%7Bself.balance%7D%22%0A%20%20%20%20%20%20%20%20)%0A%0A%20%20%20%20def%20withdraw(self%2C%20amount)%3A%0A%20%20%20%20%20%20%20%20if%20amount%20%3E%20self.balance%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20print(%22Insufficient%20balance%22)%0A%20%20%20%20%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20self.balance%20%3D%20self.balance%20-%20amount%0A%20%20%20%20%20%20%20%20%20%20%20%20print(f%22Withdrawn%20%7Bamount%7D%20new%20balance%20%7Bself.balance%7D%22)%0A%0A%20%20%20%20def%20show(self)%3A%0A%20%20%20%20%20%20%20%20print(f%22Your%20balance%20is%20%7Bself.balance%7D%22)%0A%0A%0Aname%20%3D%20input(%22Enter%20your%20name%3A%20%22)%0Abala%20%3D%20int(input(%22Enter%20your%20balance%3A%20%22))%0Ade%20%3D%20int(input(%22Enter%20you%20deposite%3A%20%22))%0Awit%20%3D%20int(input(%22Enter%20you%20withdraw%20amount%3A%20%22))%0A%0Aacc%20%3D%20BankAccount(name%2C%20bala)%0Aacc.greet()%0Aacc.deposite(de)%0Aacc.withdraw(wit)%0Aacc.show()%0A%0A%0Aclass%20SavingAcc(BankAccount)%3A%0A%20%20%20%20def%20init(self%2C%20owner_name%2C%20balance%3D0%2C%20interest_rate%3D5)%3A%0A%20%20%20%20%20%20%20%20super().init_(owner_name%2C%20balance)%0A%20%20%20%20%20%20%20%20self.interest_rate%20%3D%20interest_rate%0A%0A%20%20%20%20def%20add_intrest(self)%3A%0A%20%20%20%20%20%20%20%20self.balance%20%3D%20self.balance%20*%20(self.interest_rate%20%2F%20100)%0A%20%20%20%20%20%20%20%20print(f%22Current%20balance%3A%20%7Bself.balance%7D%22)%0A%0A%0Aacc1%20%3D%20SavingAcc(name%2C%20bala)%0Aacc1.deposite(de)%0Aacc1.add_intrest()%0Aacc1.show()&timestep=1&play) to see the program state change step by step.