python_lab_report
python_lab_report
Lab Report
December 1, 2024
2
Lab Report sangita
Contents
1 Problem Statement 2
3 Description of Implementation 6
4 Output 6
1
Lab Report sangita
1 Problem Statement
Creating a Banking Application
2
Lab Report sangita
6 import random
7
8 accounts = {}
9
3
Lab Report sangita
10 def g e n e r a t e _ a c c o u n t _ n u m b e r () :
11 return random . randint (10000 , 99999)
12
13 def main () :
14 print ( " \ nWelcome to Bank Management System ! " )
15
16 while True :
17 print ( " \ n1 . Open an Account " )
18 print ( " 2. Deposit Money " )
19 print ( " 3. Withdraw Money " )
20 print ( " 4. Display Account Details " )
21 print ( " 5. Exit " )
22
23 try :
24 choice = int ( input ( " Enter your choice : " ) )
25 except ValueError :
26 print ( " Invalid input ! Please enter a valid number . " )
27 continue
28
29 if choice == 1:
30 username = input ( " Enter your banking user name : " )
31 account_number = g e n e r a t e _ a c c o u n t _ n u m b e r ()
32 account_type = int ( input ( " Enter Account Type :\ n1 .
Savings Account \ n2 . Current Account \ n3 . Business Account \ n : - " ) )
33
34 if account_type == 1:
35 account = SavingAccount ( account_number , username ,
0 , " Savings " )
36 elif account_type == 2:
37 account = CurrentAccount ( account_number , username ,
0 , " Current " )
38 elif account_type == 3:
39 account = BusinessAccount ( account_number , username ,
0 , " Business " )
40 else :
41 print ( " Invalid Account Type ! Please try again . " )
42 continue
43
4
Lab Report sangita
56 elif choice == 3:
57 acc_num = int ( input ( " Enter your account number : " ) )
58 if acc_num in accounts :
59 amount = float ( input ( " Enter amount to withdraw : " ) )
60 accounts [ acc_num ]. withdraw ( amount )
61 else :
62 print ( " Account not found ! " )
63
64 elif choice == 4:
65 acc_num = int ( input ( " Enter your account number : " ) )
66 if acc_num in accounts :
67 accounts [ acc_num ]. display ()
68 else :
69 print ( " Account not found ! " )
70
71 elif choice == 5:
72 print ( " Thank you for using the Bank Management System .
Goodbye ! " )
73 break
74
75 else :
76 print ( " Invalid choice ! Please select a valid option . " )
77
78 if __name__ == " __main__ " :
79 main ()
5
Lab Report sangita
3 Description of Implementation
The Account class serves as the foundational blueprint for all account types in the
banking system. It encapsulates common attributes and methods that are shared
across different account types. The class focuses on core banking functionalities
such as depositing and withdrawing money. It ensures the encapsulation of common
operations, providing a base for specialized account types to extend and override as
necessary.
The saving account inherits from Account and introduces an additional attribute
specific to savings accounts interest. This class inherits the basic functionalities from
Account and adds the capability to calculate interest (to be implemented if needed
for advanced functionality). This class extends the Account class and introduces a
withdrawal limit to restrict the maximum amount that can be withdrawn at a time.
This class extends the Account class and introduces a withdrawal limit to restrict
the maximum amount that can be withdrawn at a time. This ensures tighter control
over withdrawals, a feature typical of current accounts.
BusinessAccount Class ( class further specializes the Account class by adding a
transaction fee for every withdrawal. It adds an additional layer of cost control by
charging a fee for withdrawals, mimicking real-world business account practices.
The main.py file acts as the entry point for the Banking Management System. It
uses the classes defined above to provide a user interface for interacting with the
system. The system stores all accounts in a dictionary (accounts), using account
numbers as keys. Error handling ensures invalid inputs do not crash the program.
Supports seamless extension with additional account types and features.
4 Output
Figure 1: fig 1
6
Lab Report sangita
Figure 2: fig 2
Figure 3: fig 3
Figure 4: fig 4
7
Lab Report sangita
8
Lab Report sangita
6. Exiting the System- When you’re done, select the exit option. The system thanks
you for using it and safely shuts down.
Example of Using the System:
Opening an Account: You open a Business Account with the name Jane Smith. The
system assigns you an account number, say 54321.
Depositing Money: You deposit 5, 000intoyournewaccount.T hesystemconf irmsthedeposit, andyourb
Withdrawing Money: You withdraw 1, 000.T hesystemdeducts1,050 (including a
50transactionf ee), leavingyouwith3,950.
Checking Account Details: You check your account details and see your name,
balance, and the transaction fee information.
Exiting: You select the exit option, and the system thanks you for using the service.