






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







A project proposal by Azan Khan, Noor Hassan, and Sayam Ali, demonstrating core OOP principles through a practical banking application.
This laboratory exercise introduces Object-Oriented Programming (OOP) by modelling a bank account as a class in Python. Students will learn to create objects, perform various banking operations, and observe the fundamental concept of encapsulation. The code incorporates conversational messages to simulate a realistic banking experience.
The Power of OOP: A Practical Demonstration This laboratory successfully demonstrates the power of Object- Oriented Programming (OOP) in Python by creating a simple yet interactive Account class that models real-world banking operations. Through hands-on implementation of classes, objects, attributes, and methods, students gain practical experience with encapsulation—keeping data secure and accessible only via defined actions. Additionally, the project highlights method reuse, as exemplified by the transfer function, which efficiently leverages existing withdraw and deposit functionalities.
The Account class is initialised with an account number and an optional starting balance. Upon creation, a welcoming message is displayed to the user. class Account: def init(self, account_number, initial_balance=0): self.account_number = account_number self.balance = initial_balance print(f"Account {self.account_number} created with balance £{self.balance}. Welcome!")
The withdraw method handles the removal of funds. It verifies that the withdrawal amount is positive and does not exceed the current balance, preventing overdrafts and ensuring account integrity. def withdraw(self, amount): if amount > 0 and amount <= self.balance: self.balance -= amount print(f"Withdrawal successful! Took out £{amount}. Your new balance is £{self.balance}.") else: print("Sorry, that withdrawal isn't possible. Check your balance or amount.")
The get_balance method provides a straightforward way to inquire about the current balance of the account, offering transparency to the account holder. def get_balance(self): print(f"Your current balance for account {self.account_number} is £{self.balance}.") return self.balance
Conclusion: A Robust Banking Model This project effectively showcases the practical application of OOP principles in Python to create a functional and interactive banking system. Students gained invaluable experience in class design, object interaction, encapsulation, and method reuse. Encapsulation Data security through controlled access. Method Reuse Efficient and consistent code via existing functions. User Experience Clear, conversational interaction messages.