Answer to Question #244390 in Python for dv13

Question #244390

1. The program should initialize with two variables, one called balance that starts with a float of 0, and one called otherBalance that also starts with a float of 0. [5% marks] 2. Create the following functions: i) getBalance() [5% marks] ■ This should only return the value of balance ii) getOtherBalance() [5% marks] ■ This should only return the value of otherBalance iii) printBalances() [10% marks] ■ This should call getBalance() and getOtherBalance(), and print the returned values out with a dollar symbol and two decimal places (i.e., $10.99) (Hint: you can use format() function here to print the returned values) iv) deposit(money) [15% marks]


1
Expert's answer
2021-09-30T00:57:40-0400
#Question 1
balance=0.0
otherBalance=0.0


#Question2
def  getBalance():
    return balance


def getOtherBalance():
    return otherBalance


def printBalance():
    bala=getBalance()
    bal=round(bala,2)
    other=getOtherBalance()
    other=round(other,2)
    print("Balance $",bal, "and otherBalance $", other)
    


def deposit(amount):
    balance=getBalance()
    balance+=amount
    print("Balance after deposit is $",balance)
    return(balance)



getBalance()
getOtherBalance()
printBalance()
deposit(100)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS