将返回值传递给另一个函数

时间:2019-02-27 16:02:58

标签: python return

如何将get...函数的返回值传递给addInt函数,以使investment函数正常运行?

非常感谢任何帮助。

谢谢

def addInt(initBal, deposit, term, intRate):

    for i in range(term):
        newBal = initBal * intRate
        print(round(newBal, 2))
        newBal = newBal + deposit
        initBal = newBal

    print(addInt(2000, 2000, 120, 1.025))

def getInitBal():
    initBal = input('Enter starting balance: ')
    return initBal

def getDeposit():
    deposit = input('Enter monthly deposit: ')
    return deposit

def getTerm():
    term = input('Enter investment term: ')
    return term

def getIntRate():
    intRate = input('Enter monthly interest rate: ')
    return intRate

def getArgs():
    getInitBal()
    getDeposit()
    getTerm()
    getIntRate()


def investment():
    getArgs()
    addInt(initBal, deposit, term, intRate)

investment()

0 个答案:

没有答案