-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain3.py
38 lines (33 loc) · 1.37 KB
/
main3.py
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
class BankAccount:
def __init__(self, account_number,
account_holder_name,
initial_balance=0.0):
self.__account_number = account_number
self.__account_holder_name = account_holder_name
self.__account_balance = initial_balance
def deposit(self, amount):
if amount > 0:
self.__account_balance += amount
self.__account_balance = self.__account_balance+amount
print("Deposited ₹{}. new balance: ₹{}".format(amount,self.__account_balance))
else:
print("Invalid deposit amount")
def withdraw(self, amount):
if amount > 0 and amount <= self.__account_balance:
self.__account_balance -= amount
print("withdraw ₹{}. new balance: ₹{}".format(amount,self.__account_balance))
else:
print("invalid withdraw amount or insufficient balance.")
def display_balance(self):
print("account balance for {} (account #{}): ₹{}".format(self.__account_number,
self.__account_holder_name,
self.__account_balance))
account = BankAccount(account_number = "9659646565",
account_holder_name = "yogeta",
initial_balance = 9999.9
)
#account
account.display_balance()
account.deposit(1.1)
account.withdraw(500.0)
account.withdraw(1.0)