Published Aug. 7, 2023, 9:15 a.m.
User-friendly banking project(mini): manage finances with ease. Deposit, withdraw, and check balances conveniently.
The aim of this app is to provide users with a seamless and user-friendly platform for managing their finances. It enables users to easily deposit, withdraw, and check balances, enhancing their financial control and convenience. The app aims to simplify virtual banking and promote efficient financial management.
Introduction
Bank Features
Customer
class with banking operations.bankname
for the bank's name.Bank Operations
Deposit Operation:
Withdraw Operation:
Application Flow
Welcome Message:
Customer Interaction:
Customer
object.Main Menu:
User Choice Handling:
Exit Option:
Usage Scenarios and Outputs
Example 1: Depositing and Withdrawing
Example 2: Insufficient Funds
Example 3: Exiting the Program
Conclusion
This outline provides a structured overview of the features and content included in PyDjangoboy banking application.
import sys
# Define the Customer class
class Customer:
'''Customer class with bank operations..'''
bankname = 'PyDjangoBank' # Static variable to store the bank's name
# Constructor to initialize customer details
def __init__(self, name, balance=0.0):
self.name = name
self.balance = balance
# Method to deposit funds
def deposit(self, amt):
self.balance += amt
print('Balance after deposit:', self.balance)
# Method to withdraw funds
def withdraw(self, amt):
if amt > self.balance:
print('Insufficient Funds..cannot perform this operation')
sys.exit() # Exit the program if there are insufficient funds
self.balance -= amt
print('Balance after withdrawal:', self.balance)
# Welcome message with bank's name
print('Welcome to', Customer.bankname)
# Get customer's name as input
name = input('Enter Your Name:')
# Create a Customer object
c = Customer(name)
# Main loop for banking operations
while True:
print('d-Deposit\nw-Withdraw\ne-Exit')
option = input('Choose your option:')
if option == 'd' or option == 'D':
amt = float(input('Enter amount:'))
c.deposit(amt)
elif option == 'w' or option == 'W':
amt = float(input('Enter amount:'))
c.withdraw(amt)
elif option == 'e' or option == 'E':
print('Thanks for Banking')
sys.exit() # Exit the program when the user chooses to exit
else:
print('Invalid option.. Please choose a valid option')
sys
module, which provides access to some variables used or maintained by the interpreter and to functions that interact strongly with the interpreter.Customer
.bankname
is set to 'PyDjangoBank', representing the name of the bank.__init__
is defined to initialize customer details. It takes a name
parameter along with an optional balance
parameter which defaults to 0.0.self.name
stores the customer's name and self.balance
tracks their account funds.deposit
method allows the customer to deposit funds into their account. The balance is increased by the deposited amount.withdraw
method allows the customer to withdraw funds from their account. It checks if the withdrawal amount is within the balance and performs the withdrawal if possible.Customer
class with the provided name.deposit
method is then called.withdraw
method is then called.Example 1: Depositing and Withdrawing
Welcome to PyDjangoBank
Enter Your Name: John
d-Deposit
w-Withdraw
e-Exit
Choose your option: d
Enter amount: 100
Balance after deposit: 100.0
d-Deposit
w-Withdraw
e-Exit
Choose your option: w
Enter amount: 50
Balance after withdrawal: 50.0
d-Deposit
w-Withdraw
e-Exit
Choose your option: e
Thanks for Banking
Example 2: Insufficient Funds
Welcome to PyDjangoBank
Enter Your Name: Alice
d-Deposit
w-Withdraw
e-Exit
Choose your option: d
Enter amount: 200
Balance after deposit: 200.0
d-Deposit
w-Withdraw
e-Exit
Choose your option: w
Enter amount: 300
Insufficient Funds..cannot perform this operation
Example 3: Exiting the Program
Welcome to PyDjangoBank
Enter Your Name: Bob
d-Deposit
w-Withdraw
e-Exit
Choose your option: e
Thanks for Banking
Recap of the User-Friendly Banking Application:
Encouragement for Exploration: