Python Cca
Python Cca
REPORT
on
Submitted by:
SHREEKA D R
(BRANCH/SECTION): MECHANICAL
Submitted to
1
Banking Application Procedure Oriented
# Global list to store account information
accounts = []
acc_no = str(next_account_number)
name = input("Enter Account Holder Name: ")
balance = float(input("Enter Initial Deposit: "))
account = [acc_no, name, balance]
accounts.append(account)
# 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. Exit")
choice = input("Enter your choice (1-6): ")
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':
print("✅ Exiting... Thank you for using our banking system.")
break
else:
print("✅ Invalid choice! Please try again.\n")
3
Object-Oriented Code:
class Account:
next_account_number = 1001
accounts = []
def find_account(acc_no):
for account in Account.accounts:
if account.acc_no == acc_no:
return account
return None
def check_balance(self):
print(f"✅ Current balance for account {self.acc_no} is ₹{self.balance}\n")
def close_account(self):
Account.accounts.remove(self)
print(f"✅ Account {self.acc_no} closed successfully.\n")
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. Exit")
choice = input("Enter your choice (1-6): ")
if choice == '1':
name = input("Enter Account Holder Name: ")
balance = float(input("Enter Initial Deposit: "))
account = Account(name, balance)
4
print(f"✅ Account created successfully! Your Account Number is:
{account.acc_no}\n")
else:
print("✅ Invalid choice! Please try again.\n")
main()
5
6
7
OBJECT-ORIENTED CODE: Implemented display all accounts
class Account:
next_account_number = 1001
accounts = []
def find_account(acc_no):
for account in Account.accounts:
if account.acc_no == acc_no:
return account
return None
def check_balance(self):
print(f"✅ Current balance for account {self.acc_no} is ₹{self.balance}\n")
def close_account(self):
Account.accounts.remove(self)
print(f"✅ Account {self.acc_no} closed successfully.\n")
def display_all_accounts():
if not Account.accounts:
print("📂 No accounts to display.\n")
else:
print("📂 All Accounts:")
for acc in Account.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. Exit")
8
print("7. Display All Accounts")
choice = input("Enter your choice (1-7): ")
if choice == '1':
name = input("Enter Account Holder Name: ")
balance = float(input("Enter Initial Deposit: "))
account = Account(name, balance)
print(f"✅ Account created successfully! Your Account Number is:
{account.acc_no}\n")
else:
print("✅ Invalid choice! Please try again.\n")
main()
9
10
11
PROS/CONS PROGRAM ORIENTED CONCEPT TO OBJECT
ORIENTED CONCEPT:
12
Student USN: 1BY24ME050 Faculty Incharge:
Signature
13