Python 3
Python 3
class MinimumBalanceError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return str(self.value)
#balance = int(input())
#choice = int(input())
#amount = int(input())
def Bank_ATM(balance,choice,amount):
# Write your code here
#balance = int(input())
#choice = int(input())
#amount = int(input())
if (balance < 500):
print("As per the Minimum Balance Policy, Balance must be at least
500")
elif (choice == 1):
try:
if (choice == 1 and amount < 2000):
raise MinimumDepositError("The Minimum amount of Deposite should be
2000")
balance = balance + amount
print("Updated Balance Amount: " + str(balance))
#print("Updated Balace Amount: " + str(balance))
except MinimumDepositError as md:
print(md)
elif (choice == 2):
try:
if (choice == 2 and amount < 500):
raise MinimumBalanceError("You cannot withdraw this amount due to
Minimum Balace Policy")
balance = balance - amount
print("Updated Balance Amount: " + str(balance))
except MinimumBalanceError as mb:
print(mb)
class MinimumDepositError(Exception):
#__init__()
def __init__(self):
#message for MinimumDepositError
self.msg = ("The Minimum amount of Deposit should be 2000.")
super().__init__(self.msg)
#user defined Exception MinimumBalanceError
class MinimumBalanceError(Exception):
#__init__()
def __init__(self):
#message for MinimumBalanceError
self.msg = ("You cannot withdraw this amount due to Minimum Balance
Policy")
super().__init__(self.msg)
def Bank_ATM(balance,choice,amount):
# Write your code here
#if balance is less than 500
if balance < 500:
#raises ValueError
msg = ("As per the Minimum Balance Policy, Balance must be at least 500")
raise ValueError(msg)
#if deposit
if choice == 1:
#if deposit amount less than 2000
if amount < 2000:
#raises MinimumDepositError
raise MinimumDepositError
#otherwise
else:
#updates balance
balance = balance + amount
#prints updated balance
print("Updated Balance Amount: ", balance)
#if withdrawal
if choice == 2:
#if balance after withdrawal is less than 500
if balance - amount < 500:
#raises MinimumBalanceError
raise MinimumBalanceError
else:
#updates balance
balance = balance - amount