Himanshu Python Cca
Himanshu Python Cca
MANAGEMENT
(An Autonomous Institution, Affiliated to VTU, Belagavi)
REPORT
on
Submitted by,
Himanshu D Kolchar
(BRANCH/SECTION): Mechanical
Submitted to
Asst.Prof. Sowmya K
Assistant Professor, Department of AI & ML
Banking Application Procedure Oriented
# Main menu
def main():
while True:
print("===== BANKING SYSTEM MENU =====")
print("1. Create Account")
print("2. Deposit")
print("3. Withdraw")
print("4. Check Balance")
print("5. Close Account")
print("6. Display All Accounts")
print("7. Exit")
choice = input("Enter your choice (1-7): ")
if choice == '1':
create_account()
elif choice == '2':
deposit()
elif choice == '3':
withdraw()
elif choice == '4':
check_balance()
elif choice == '5':
close_account()
elif choice == '6':
display_all_accounts()
elif choice == '7':
print("Exiting... Thank you for using our banking system.")
break
else:
print("Invalid choice! Please try again.\n")
class Account:
accounts = []
next_account_number = 1001
def find_account_by_number(acc_no):
for acc in Account.accounts:
if acc.acc_no == acc_no:
return acc
return None
def create_account():
name = input("Enter Account Holder Name: ")
try:
balance = float(input("Enter Initial Deposit: "))
new_acc = Account(name, balance)
print(f"Account created successfully! Your Account Number is:
{new_acc.acc_no}\n")
except ValueError:
print("Invalid amount entered.\n")
@staticmethod
def deposit():
acc_no = input("Enter Account Number for Deposit: ")
acc = Account.find_account_by_number(acc_no)
if acc:
try:
amount = float(input("Enter amount to deposit: "))
acc.balance += amount
print(f"₹{amount} deposited. New balance:
₹{acc.balance}\n")
except ValueError:
print("Invalid amount.\n")
else:
print("Account not found!\n")
@staticmethod
def withdraw():
acc_no = input("Enter Account Number for Withdrawal: ")
acc = Account.find_account_by_number(acc_no)
if acc:
try:
amount = float(input("Enter amount to withdraw: "))
if amount <= acc.balance:
acc.balance -= amount
print(f"₹{amount} withdrawn. Remaining balance:
₹{acc.balance}\n")
else:
print("Insufficient balance!\n")
except ValueError:
print("Invalid amount.\n")
else:
print("Account not found!\n")
@staticmethod
def check_balance():
acc_no = input("Enter Account Number to Check Balance: ")
acc = Account.find_account_by_number(acc_no)
if acc:
print(f"Current balance for account {acc.acc_no} is
₹{acc.balance}\n")
else:
print("Account not found!\n")
@staticmethod
def close_account():
acc_no = input("Enter Account Number to Close: ")
acc = Account.find_account_by_number(acc_no)
if acc:
Account.accounts.remove(acc)
print(f"Account {acc_no} closed successfully.\n")
else:
print("Account not found!\n")
@staticmethod
def display_all_accounts():
if not Account.accounts:
print("No accounts to display.\n")
else:
print("All Accounts (sorted by Account Number):")
sorted_accounts = sorted(Account.accounts, key=lambda a:
int(a.acc_no))
for acc in sorted_accounts:
print(f"Account No: {acc.acc_no}, Name: {acc.name},
Balance: ₹{acc.balance}")
print()
def main():
while True:
print("===== BANKING SYSTEM MENU =====")
print("1. Create Account")
print("2. Deposit")
print("3. Withdraw")
print("4. Check Balance")
print("5. Close Account")
print("6. Display All Accounts")
print("7. Exit")
choice = input("Enter your choice (1-7): ")
if choice == '1':
Account.create_account()
elif choice == '2':
Account.deposit()
elif choice == '3':
Account.withdraw()
elif choice == '4':
Account.check_balance()
elif choice == '5':
Account.close_account()
elif choice == '6':
Account.display_all_accounts()
elif choice == '7':
print("Exiting... Thank you for using our banking system.")
break
else:
print("Invalid choice! Please try again.\n")
class Account:
def init (self, acc_no, name, balance):
self.acc_no = acc_no
self.name = name
self.balance = balance
def check_balance(self):
print(f"Current balance for account {self.acc_no} is
₹{self.balance}\n")
class Bank:
def init (self):
self.accounts = []
self.next_account_number = 1001
def create_account(self):
name = input("Enter Account Holder Name: ")
try:
balance = float(input("Enter Initial Deposit: "))
except ValueError:
print("Invalid input for balance!\n")
return
acc_no = str(self.next_account_number)
account = Account(acc_no, name, balance)
self.accounts.append(account)
self.next_account_number += 1
print(f"Account created successfully! Your Account Number is:
{acc_no}\n")
def deposit_to_account(self):
acc_no = input("Enter Account Number for Deposit: ")
acc = self.find_account_by_number(acc_no)
if acc:
try:
amount = float(input("Enter amount to deposit: "))
acc.deposit(amount)
except ValueError:
print("Invalid amount!\n")
else:
print("Account not found!\n")
def withdraw_from_account(self):
acc_no = input("Enter Account Number for Withdrawal: ")
acc = self.find_account_by_number(acc_no)
if acc:
try:
amount = float(input("Enter amount to withdraw: "))
acc.withdraw(amount)
except ValueError:
print("Invalid amount!\n")
else:
print("Account not found!\n")
def check_account_balance(self):
acc_no = input("Enter Account Number to Check Balance: ")
acc = self.find_account_by_number(acc_no)
if acc:
acc.check_balance()
else:
print("Account not found!\n")
def close_account(self):
acc_no = input("Enter Account Number to Close: ")
acc = self.find_account_by_number(acc_no)
if acc:
self.accounts.remove(acc)
print(f"Account {acc_no} closed successfully.\n")
else:
print("Account not found!\n")
def search_account_by_name(self):
name = input("Enter Account Holder Name to Search: ")
results = self.find_accounts_by_name(name)
if results:
print(f"Found {len(results)} account(s) with name '{name}':")
for acc in results:
print(f"Account No: {acc.acc_no}, Name: {acc.name},
Balance: ₹{acc.balance}")
print()
else:
print("No account found with that name.\n")
def main():
bank = Bank()
while True:
print("===== BANKING SYSTEM MENU =====")
print("1. Create Account")
print("2. Deposit")
print("3. Withdraw")
print("4. Check Balance")
print("5. Close Account")
print("6. Search Account by Name")
print("7. Exit")
choice = input("Enter your choice (1-7): ")
if choice == '1':
bank.create_account()
elif choice == '2':
bank.deposit_to_account()
elif choice == '3':
bank.withdraw_from_account()
elif choice == '4':
bank.check_account_balance()
elif choice == '5':
bank.close_account()
elif choice == '6':
bank.search_account_by_name()
elif choice == '7':
print("Exiting... Thank you for using our banking system.")
break
else:
print("Invalid choice! Please try again.\n")
# Run the
program main()
PROS/CONS PROGRAM ORIENTED CONCEPT TO OBJECT
ORIENTED CONCEPT:
Signature