avatarJanita Williamson

Summary

The website content provides a tutorial for creating a simple bank account OOP (Object-Oriented Programming) project in Python, which includes user and bank account information classes, and functions for depositing, withdrawing, and viewing account balance.

Abstract

The provided web content outlines an educational project aimed at enhancing OOP skills in Python. It introduces a basic banking application structure that consists of two classes: User for storing personal details and Bank for managing account balance and transactions. The Bank class inherits from User and adds methods for depositing, withdrawing funds, and viewing the account balance. The article also includes a code snippet that demonstrates the implementation of these classes and methods, along with a simple interface for user interaction. The author encourages readers to engage with the code, either by using it as is or customizing it to fit their needs. Additionally, the author invites feedback and shares their LinkedIn and GitHub profiles for further connection.

Opinions

  • The author believes that OOP projects are fundamental for industry-level programming and that this bank account example serves as a good refresher for developers.
  • The project is presented as beneficial for those in the fin-tech space or for any developer looking to practice OOP concepts.
  • The author expresses enthusiasm and encourages readers to enjoy the programming exercise, suggesting a sense of community and shared learning.
  • By providing LinkedIn and GitHub profiles, the author shows a willingness to network and collaborate with other developers.
  • The author endorses an AI service, ZAI.chat, as a cost-effective alternative to ChatGPT Plus (GPT-4), indicating a preference for value-for-money tools in the tech industry.

OOP Project: Bank Account- Python

OOP projects: (object-oriented programming) they are the fundamental needs of industry- level projects!

This is a simple program that is used to mock a bank account that has withdraw & deposit functions. If you are in the fin-tech space or just a developer wanting a refresher program. Then this project will help you on your OOP skills & implement basic python functions.

What we need to include:

Parent Class: User Information

  • this is where the details for user is stored
  • includes functions for the user details

Child Class: Bank Information

  • this is where the details for account balance is stored
  • this is where the details for the amount is stored
  • it allows for withdrawal, deposits & you can view the balance

Open up your IDE (I used VSC). You can either just copy the code below or customize it as you like & use it as a template!

#Parent Class
class User()Ni:
    def __init__(self,name,age,gender):
        self.name = name
        self.age  = age
        self.gender = gender

    def show_details(self):
        print("Personal Details")
        print("")
        print("Name ", self.name)
        print("Age  ", self.age)
        print("Gender ", self.gender)

    
#Child Class
class Bank(User):
    def __init__(self,name,age,gender):
        super().__init__(name,age,gender)
        self.balance = 0

    def deposit(self,amount):
        self.amount = amount
        self.balance = self.balance + self.amount
        print("Account balance has been updated : $", self.balance)

    def withdraw(self,amount):
        self.amount = amount
        if self.amount > self.balance:
            print("Insufficient Funds | Balance Available : $", self.balance)
        else:
            self.balance = self.balance - self.amount
            print("Account balance has been updated : £", self.balance)
    
    def view_balance(self):
        self.show_details()
        print("Account balance: $", self.balance)

def cont():
  input("\n\nPress enter to continue\n\n")

exit = 0
while True:
  name = Bank(input("Enter name: "), int(input("Enter Age: ")), input("Enter Gender: ")) 
  options = input("\n\nwhat would you like to do (enter a number)?\n\n1. Withdraw\n2. Deposit\n3. View Account summary\n4. view balance\n5. Exit \n>>")
  if options == '5':
    exit = 1
    break
  if options == '3':
    name.show_details()
    cont()
  elif options == '4': 
    name.view_balance()
    cont()
  elif options == "1":
    name.withdraw(int(input("How much would you like to withdraw?: ")))
    cont()
  elif options == "2": 
    name.deposit(int(input("How much would you like to deposit?: "))) 
    cont()

I hope you enjoyed this quick & simple OOP Python program!

Drop a comment if you tried it out & customized it ☺️.

Let’s Connect!

My Linkedin profile: https://www.linkedin.com/in/janita-williamson

My GitHub username: MrsTorres https://github.com/MrsTorres/python-.git

A visual diary of my coffee induced journey transitioning from healthcare to the tech world! @caffeinatedtechie

More content at PlainEnglish.io.

Sign up for our free weekly newsletter. Follow us on Twitter, LinkedIn, YouTube, and Discord.

Interested in scaling your software startup? Check out Circuit.

Python
Women In Tech
Oop
Automation
DevOps
Recommended from ReadMedium