Skip to content

Python OOPs Task: Create a Simple Bank Account System #16

@codewithdhruba01

Description

@codewithdhruba01

Problem: Implement a Simple Bank Account System Using OOPs in Python

Objective:
Use Object-Oriented Programming concepts in Python to build a basic bank account system.


✅ Concepts to Implement:

  • Encapsulation
  • Inheritance
  • Polymorphism
  • Abstraction (optional)

🛠️ Requirements:

  1. Create a base class BankAccount with the following:

    • Attributes: account_holder, balance

    • Methods:

      • deposit(amount)
      • withdraw(amount)
      • display_balance()
  2. Encapsulation:

    • Make balance a private variable using double underscore (__balance)
    • Use getter method if needed
  3. Inheritance:

    • Create a subclass SavingsAccount that inherits from BankAccount
    • Add an attribute: interest_rate
    • Method: apply_interest() which updates balance
  4. Polymorphism:

    • Override display_balance() in the subclass to also show interest rate
  5. Abstraction (Optional):

    • Use the abc module to create an abstract base class if needed

Example Usage:

acc = SavingsAccount("John Doe", 1000, 0.05)
acc.deposit(500)
acc.withdraw(200)
acc.apply_interest()
acc.display_balance()

Expected Output:

Deposited 500
Withdrawn 200
Interest applied
Account Holder: John Doe
Balance: 1365.0
Interest Rate: 5.0%

📌 Acceptance Criteria:

  • Code must be in Python.
  • Step : Go to Learn-python-language Create a Folder : then Start a Project
  • Follow clean naming and formatting.

Checklist:

  • Create BankAccount class
  • Implement encapsulation with private balance
  • Inherit SavingsAccount from BankAccount
  • Override a method (polymorphism)
  • (Optional) Use abstract class
  • Add example usage and test the output

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestgood first issueGood for newcomershelp wantedExtra attention is neededquestionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions