Created
February 8, 2020 15:09
-
-
Save manojnaidu619/f4ca2b5319ffdb26e65eb3fc39d75f50 to your computer and use it in GitHub Desktop.
Banking Management system in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import randint | |
class Account: | |
def __init__(self): | |
self.accounts = {} | |
self.name = None | |
self.initialDeposit = None | |
def createAccount(self, name, initialDeposit): | |
accountNumber = randint(10000,99999) | |
self.accounts[accountNumber] = [name, initialDeposit] | |
self.beautifyPrint(f"Account created Successfully!, your account number is {accountNumber}") | |
self.name = self.accounts[accountNumber][0] | |
self.initialDeposit = self.accounts[accountNumber][1] | |
def authenticate(self, name, accountNumber): | |
if accountNumber in self.accounts.keys() and self.name == name: | |
return True | |
else: | |
return False | |
def withdraw(self, withdrawalAmount): | |
if self.initialDeposit < withdrawalAmount: | |
self.beautifyPrint("Insufficient Balance!") | |
else: | |
self.initialDeposit -= withdrawalAmount | |
self.beautifyPrint("Amount Withdrawal Successfull!") | |
self.displayCurrentBalance() | |
def deposit(self, depositAmount): | |
self.initialDeposit += depositAmount | |
self.beautifyPrint("Amount Deposited Successfully!") | |
self.displayCurrentBalance() | |
def displayCurrentBalance(self): | |
print("---------------------------------------") | |
print("Current Balance is", self.initialDeposit) | |
print("---------------------------------------") | |
def beautifyPrint(self, message): | |
print("---------------------------------------") | |
print(message) | |
print("---------------------------------------") | |
account = Account() | |
while 1: | |
print("Enter 1 to create a new Savings account") | |
print("Enter 2 to access your Savings account") | |
print("Enter 3 to quit") | |
userChoice = int(input()) | |
if userChoice is 1: | |
userName = str(input("Enter your Name : ")) | |
deposit = int(input("Enter initial deposit : ")) | |
account.createAccount(userName, deposit) | |
elif userChoice is 2: | |
userName = str(input("Enter your Name : ")) | |
accountNumber = int(input("Enter your account Number : ")) | |
if account.authenticate(userName, accountNumber): | |
account.beautifyPrint("Account authenticated successfully!") | |
while 1: | |
print("Enter 1 to Withdraw") | |
print("Enter 2 to Deposit") | |
print("Enter 3 to Display current balance") | |
print("Enter 4 to go back") | |
choice = int(input()) | |
if choice is 1: | |
withdrawAmount = int(input("Enter the Withdrawal Amount : ")) | |
account.withdraw(withdrawAmount) | |
elif choice is 2: | |
depositAmount = int(input("Enter the Deposit amount : ")) | |
account.deposit(depositAmount) | |
elif choice is 3: | |
account.displayCurrentBalance() | |
elif choice is 4: | |
break | |
else: | |
print("Invalid credentials!") | |
elif userChoice is 3: | |
print("GoodBye!") | |
quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment