Answered step by step
Verified Expert Solution
Question
1 Approved Answer
python pls Suppose we're writing a program for an ATM, that handles actions such as bank account withdrawals (removing funds from a bank account). We
python pls
Suppose we're writing a program for an ATM, that handles actions such as bank account withdrawals (removing funds from a bank account). We define a namedtuple representing a bank account below: Account = namedtuple('Account', 'id balance') The id attribute is an integer, and the balance attribute is a float. Write the function make_withdrawal, which takes as an argument an Account object, representing a customer's bank account. The function should prompt the user (taking input from the shell) for an amount of money to withdraw from the bank account - with a valid amount satisfying these conditions: the amount must be a positive integer that is a multiple of 20. the amount cannot be greater than the current balance of the bank account (i.e. you can't withdraw more funds than is available in the account). The function should prompt the user repeatedly until a valid amount is entered, and return a modified version of the Account object, with the new remaining balance after withdrawal. If the function receives an empty input (e.g. user types nothing and presses Enter), then the function should end and return the given account object unchanged. Examples (Bolded, italic text indicates user input, normal text indicates output) # make_withdrawal (Account (123, 95.50)) Amount: -5 INVALID Amount: 20.0 INVALID Amount: 40 # returns Account(123, 55.50) # make_withdrawal (Account(456, 150.00)) Amount: 175 INVALID Amount: 150.01 INVALID Amount: # returns Account(456, 150.00) def make_withdrawal(account: Account) -> AccountStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started