Question

Write a Python program which simulates how a bank account works. (1) create a global constant...

Write a Python program which simulates how a bank account works.

  • (1) create a global constant INTEREST_RATE as the interest rate, which is assigned value 0.01.
  • (2) create a global variable balance, which is initialized to 1000.
  • (3) define a function named deposit which takes no parameter, it asks user to enter the amount of money that will be deposited into this account, then updates the global variable balance (which should increase by the amount of the deposit) and prints out the updated balance.
  • (4) define a function named cal_interest which takes no parameter. This function will calculate and print the amount of annual interest using the following formula:

  the amount of interest = balance * INTEREST_RATE

  • (5) define the main function that calls the above two functions.

Execute the program.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

CODE :

OUTPUT :

Raw_Code :

INTREST_RATE = 0.01 #declaring intrest rate and balance globally
balance = 1000
def deposite():
   amount = float(input("enter the amount of money :")) #taking amount as input from the user
   global balance       #global keyword that indicate that we are change the value of global variable
   balance += amount       #updating balance
   print("The Updated balance is : ",balance) #printing the balance

def cal_intrest():       #function to calculate intrest
   intrest = balance*INTREST_RATE       #calculating intrest using formula given
   print("The Intrest is : ",intrest)   #printing intrest

def main():   #main function calling two functions
   deposite()
   cal_intrest()


if __name__ == "__main__":

   main()       #callign main function

***********Comment me for any Queries and Rate me up*********

Add a comment
Know the answer?
Add Answer to:
Write a Python program which simulates how a bank account works. (1) create a global constant...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C program to simulate deposit/withdraw activities on a banking account. (Hint: you might want...

    Write a C program to simulate deposit/withdraw activities on a banking account. (Hint: you might want to review Lab 3 slides.) (25 points)  Declare the balance as a global variable and initialize it to 600.  Write two functions, one for withdraw, the other for deposit. Both withdraw and deposit functions have one parameter, which represent the amount to withdraw or deposit. The functions deduct the balance and add to the balance one dollar at a time, respectively. Therefore,...

  • 1) Translate the following equation into a Python assignment statement 2) Write Python code that prints...

    1) Translate the following equation into a Python assignment statement 2) Write Python code that prints PLUS, MINUS, O ZERO, depending on the value stored in a variable named N. 3) What is printed by: 3 - 1 while 5: while 10 Print ) Page 1 of 9 4) Write a Python while loop that reads in integers until the user enters a negative number, then prints the sum of the numbers. 1-2 of 9 4) Write a Python while...

  • DATA PROGRAMMING: PYTHON Be sure to use sys.argv NOT input. Write a program and create a...

    DATA PROGRAMMING: PYTHON Be sure to use sys.argv NOT input. Write a program and create a function called inch2cm that takes one number in inches as a parameter, converts it to the centimeters and prints the result. The program output is shown below. Input: 14 Output: 14 inches = 35.56 centimeter Write a program and create the following functions: shapes(): takes the shape name and a number as parameters, and calls the proper function to calculate the area. areaCircle(): take...

  • Answer in Python: Show all code: Modify the code used to solve the below question so...

    Answer in Python: Show all code: Modify the code used to solve the below question so that calcFinalBalance() returns the final balance to main(), and main() prints the final balance out: Write a program that contains a main function and a called function called calcFinalBalance(). The main function asks the user for the amount of money to be deposited in a bank account, the interest rate, and the number of years it will be in that account. The interest rate...

  • Design a bank account class named Account that has the following private member variables:

    Need help please!.. C++ programDesign a bank account class named Account that has the following private member variables: accountNumber of type int ownerName of type string balance of type double transactionHistory of type pointer to Transaction structure (structure is defined below) numberTransactions of type int totalNetDeposits of type static double.The totalNetDeposits is the cumulative sum of all deposits (at account creation and at deposits) minus the cumulative sum of all withdrawals. numberAccounts of type static intand the following public member...

  • Project 9-2: Account Balance Calculator Create an application that calculates and displays the starting and ending...

    Project 9-2: Account Balance Calculator Create an application that calculates and displays the starting and ending monthly balances for a checking account and a savings account. --->Console Welcome to the Account application Starting Balances Checking: $1,000.00 Savings:  $1,000.00 Enter the transactions for the month Withdrawal or deposit? (w/d): w Checking or savings? (c/s): c Amount?: 500 Continue? (y/n): y Withdrawal or deposit? (w/d): d Checking or savings? (c/s): s Amount?: 200 Continue? (y/n): n Monthly Payments and Fees Checking fee:              $1.00 Savings...

  • Using C programming please 5. Write a multithreaded program to do the following: Accepts two positive...

    Using C programming please 5. Write a multithreaded program to do the following: Accepts two positive integers from the command line as the amounts to withdraw a. and deposit from an account. b. Creates two threads to perform withdraw and deposit operations repectively. Passes the amount to withdraw/deposit as the parameter to thread's runner function c. Waits for both threads to terminate. Since both threads need to update the account balance, it is necessary to protect sections. You may use...

  • Please help JAVA Part II: Programming Module (80 marks): Write a banking program that simulates the operation of your l...

    Please help JAVA Part II: Programming Module (80 marks): Write a banking program that simulates the operation of your local bank. You should declare the following collection of classes: 1) An abstract class Customer: each customer has: firstName(String), lastName (String), age (integer), customerNumber (integer) - The Class customer has a class variable lastCustomerNumber that is initialized to 9999. It is used to initialize the customerNumber. Hence, the first customer number is set to 9999 and each time a new customer...

  • The program needs to be in python : First, create a BankAccount class. Your class should...

    The program needs to be in python : First, create a BankAccount class. Your class should support the following methods: class BankAccount (object): """Bank Account protected by a pin number.""" def (self, pin) : init "n"Initial account balance is 0 and pin is 'pin'."" self.balance - 0 self.pin pin def deposit (self, pin, amount): """Increment account balance by amount and return new balance.""" def withdraw (self, pin, amount): """Decrement account balance by amount and return amount withdrawn.""" def get balance...

  • Write a Python (version 3.5.2) program that simulates how often certain hands appear in Yahtzee. In...

    Write a Python (version 3.5.2) program that simulates how often certain hands appear in Yahtzee. In Yahtzee, you roll five dice and then use those dice to make certain combinations. For example, the Yahtzee combination is formed by all five dice having the same value. A large straight occurs when all of the dice are in consecutive order (e.g., 1,2,3,4,5 or 2,3,4,5,6). If you haven’t played Yahtzee, you can find out more from various online sources such as Wikipedia. Once...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT