Question

In: Computer Science

This is in python3.. Calculate the Balance - Deposit If the action is Deposit 'D’, use...

This is in python3..

Calculate the Balance - Deposit

If the action is Deposit 'D’, use a deposit function to add funds to the account

Deposit Input

userchoice = input ("What would you like to do?\n")
userchoice = 'B'
deposit_amount = 200

Deposit Output

What would you like to do?
How much would you like to deposit today?
Deposit was $200, current balance is $700.25

Customer Deposit

  1. Write a function called `deposit`.
  2. Request from the user the amount to be deposited. This value should be stored in a variable called `deposit_amount`. Use both the `input` and `float` methods in order to ensure the `deposit_amount` is a float value.
  3. Calculate a new account balance.
  4. The calculation for depositing funds into the account is `account_balance = account_balance + deposit_amount`.
  5. Print the new account balance.

need to add to this program below. use a deposit function to add funds to the account.

import sys# importing the sys library
# account balance
account_balance = float(500.25)
#PPrint the balance
# This is a custom function, it returns the current balance upto 2 decimal places
def printbalance():
print('Your current balance:')
return account_balance
#the function for deposit
#This is a custom function
def deposit():
deposit_amount = float(input("Enter amount to deposit : ")) # takes in input for deposit amount
balance = account_balance + deposit_amount #calculates balance
print("Deposit was $%2f, current balance is $%2f" %(deposit_amount,balance)) # prints out the balance
#function for withdraw
#this is a custom function
def withdraw():
withdraw_amount = float(input("Enter amount to withdraw")) # takes in the withdraw amount
if(withdraw_amount > account_balance): #checks whether the amount is more than balance or not
print("$%2f is greater than account balance $%2f\n" %(withdraw_amount,account_balance)) #if yes then
else:
balance = account_balance - withdraw_amount
print("$%2f was withdrawn, current balance is $%2f" % (withdraw_amount, balance))
# User Input goes here, use if/else conditional statement to call function based on user input

userchoice = input("What would you like to do?\n")

if (userchoice == 'D'):
# here deposit function is called
deposit()
elif userchoice == 'W':
# here withdraw function is called
withdraw()
elif userchoice == 'B':
# here printbalance function is called
balance=printbalance()
print('{:.2f}'.format(balance))
else:
# it ends the program execution
sys.exit()

Solutions

Expert Solution

import sys  # importing the sys library

# account balance

account_balance = float(500.25)

# PPrint the balance

# This is a custom function, it returns the current balance upto 2 decimal places

def printbalance():

    print('Your current balance:')

    return account_balance

# the function for deposit

# This is a custom function

def deposit():

    # takes in input for deposit amount

    deposit_amount = float(

        input("How much would you like to deposit today?\n"))

    balance = account_balance + deposit_amount  # calculates balance

    print("Deposit was $%.2f, current balance is $%.2f" %

          (deposit_amount, balance))  # prints out the balance

# function for withdraw

# this is a custom function

def withdraw():

    # takes in the withdraw amount

    withdraw_amount = float(input("Enter amount to withdraw"))

    if(withdraw_amount > account_balance):  # checks whether the amount is more than balance or not

        print("$%2f is greater than account balance $%2f\n" %

              (withdraw_amount, account_balance))  # if yes then

    else:

        balance = account_balance - withdraw_amount

        print("$%2f was withdrawn, current balance is $%2f" %

              (withdraw_amount, balance))

# User Input goes here, use if/else conditional statement to call function based on user input

userchoice = input("What would you like to do?\n")

if (userchoice == 'D'):

    # here deposit function is called

    deposit()

elif userchoice == 'W':

    # here withdraw function is called

    withdraw()

elif userchoice == 'B':

    # here printbalance function is called

    balance = printbalance()

    print('{:.2f}'.format(balance))

else:

    # it ends the program execution

    sys.exit()

Screenshot of code:

Output:


Related Solutions

Deposit function. Calculate the Balance - Deposit If the action is Deposit 'D’, use a deposit...
Deposit function. Calculate the Balance - Deposit If the action is Deposit 'D’, use a deposit function to add funds to the account Deposit Input userchoice = input ("What would you like to do?\n") userchoice = 'B' deposit_amount = 200 Deposit Output What would you like to do? How much would you like to deposit today? Deposit was $200, current balance is $700.25 Write a function called `deposit`. Request from the user the amount to be deposited. This value should...
If the action is Balance 'B’, use a print balance function to return and print an...
If the action is Balance 'B’, use a print balance function to return and print an account balance. You will need to write a function called printbalance. a. Create a prompt for the user to input the account action. There are three possible actions: Code Action Function D Deposit deposit_amount W Withdrawal withdrawal_amount B Account Balance account_balance Create a function to print the account_balance, print the account actions and create the action for outputting the account balance outputting. Input Information...
Please solve the following question by Python3. Code the function calc_tot_playtime to calculate the total playtime...
Please solve the following question by Python3. Code the function calc_tot_playtime to calculate the total playtime by user and game. Each element in input is of the format "user_id, game_id, total_playtime_in_minute". Input is a list of strings of the above format. Output should be sorted by user_id, game_id in ascending order. Example: Input: ["1,10,20", "1,15,10m", "1,10,10m", "2,10,40m", "2, 20, 10m"] output: [('1', '10', 30), ('1', '15', 10), ('2', '10', 40), ('2', '20', 10)] Functions are defined below: def calc_total_playtime(input_data=None): """...
Explain the mode of action of anti D prophylaxis in a D negative mother ? (300...
Explain the mode of action of anti D prophylaxis in a D negative mother ? (300 words max)
The Bank Statement Balance is $10,000. The Book Balance is $12,000. The is a Deposit in...
The Bank Statement Balance is $10,000. The Book Balance is $12,000. The is a Deposit in Transit of $2000. There is an Outstanding Check of $1000. There is an NSF Check from a customer of $1000. Based on this data, complete a bank reconciliation
Python3 *Use Recursion* Write a function called smallest_sum(A,L) where A is the value and L is...
Python3 *Use Recursion* Write a function called smallest_sum(A,L) where A is the value and L is a list of ints. smallest_sum should return the length of the smallest combinations of L that add up to A if there are no possible combinations then float("inf") is returned. Examples smallest_sum(5, [2, 3]) == 2 smallest_sum(313, [7, 24, 42]) == 10 smallest_sum(13, [8, 3, 9, 6]) == float(‘‘inf’’) No Loops and map/reduce functions are allowed
use python3 language and need answer ASAP please thank you. The primary sources of calories in...
use python3 language and need answer ASAP please thank you. The primary sources of calories in food are fat, carbohydrate, and protein. Proteins and carbohydrates have four calories per gram, and fat has nine calories per gram. For example, on a box of Honey Nut Cheerios, it says that a serving has 1.5 grams of fat, 22 grams of carbohydrates, and 2 grams of protein. That works out to: 1.5 * 9 + 22 * 4 + 2 * 4...
With an initial deposit of $100, and and interest rate of 12%, the balance in a...
With an initial deposit of $100, and and interest rate of 12%, the balance in a bank account after t years is f(t) = 100(1.12)t dollars. (a) Find the average rate of change over [0, 0.5] and [0, 1]. (Round your answers to two decimal places.) (c) Estimate the instantaneous rate of change at t = 0.5 by computing the average rate of change over intervals to the left and right of t = 0.5. (Round your answers to four...
A. Calculate the currency-to-deposit ratio (c), the excess-reserves-to-deposit ratio (e) and the money multiplier (m) given...
A. Calculate the currency-to-deposit ratio (c), the excess-reserves-to-deposit ratio (e) and the money multiplier (m) given the following values: rr = 0.20 C = $320 billion D = $1,000 billion ER = $60 billion B. Calculate total required reserves (RR), total actual reserves (AR) and the monetary base (MB). C. Now assume the FED lowers the required reserve ratio to 0.10. Calculate the new money multiplier (m’) and the new money supply (M1). D. Calculate the new level of deposits...
a. Use the appropriate formula to determine the periodic deposit.
a. Use the appropriate formula to determine the periodic deposit. b. How much of the financial goal comes from deposits and how much comes from interest? 
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT