-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday_10_practice.py
More file actions
65 lines (57 loc) · 2.09 KB
/
Copy pathday_10_practice.py
File metadata and controls
65 lines (57 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# ATM Simulator Features:
# PIN verification
# Deposit
# Withdraw
# Transaction history
class Bank:
def __init__(self,name,bname,amount,pin):
self.name=name
self.bname=bname
self.amount=amount
self.pin=pin
# added
self.history=[]
def deposit(self):
user_pin=int(input("Enter the pin to use: "))
if self.pin==user_pin:
print(f"{self.name} can use the atm to deposit: ")
user_deposit_amount=int(input("enter the amount to deposit: "))
self.amount=self.amount+user_deposit_amount
# added
self.history.append(f"Deposited ₹{user_deposit_amount}")
else:
print("u have entered the wrong pin")
print(f"ur updated balance is {self.amount}")
def withdraw(self):
user_pin=int(input("Enter the pin to use: "))
if self.pin==user_pin:
print(f"{self.name} can use the atm to withdraw: ")
user_withdraw_amount=int(input("enter the amount to withdraw: "))
if user_withdraw_amount<=self.amount:
self.amount=self.amount-user_withdraw_amount
# added
self.history.append(f"Withdrawn ₹{user_withdraw_amount}")
else:
print("insufficient balance")
else:
print("u have entered the wrong pin")
print(f"ur updated balance is {self.amount}")
def show_balance(self):
print(f"u r current balance is = {self.amount}")
def transaction_history(self):
if len(self.history)==0:
print("No transactions yet")
else:
print("\nTransaction History")
for i in self.history:
print(i)
name=input("Enter you name: ")
bname=input("Enter which bank u want: ")
amount=int(input("Enter the aount u want to submit in bank: "))
pin=int(input("Enter the pin no: "))
user1=Bank(name,bname,amount,pin)
user1.show_balance()
user1.deposit()
user1.withdraw()
# added
user1.transaction_history()