📜  尝试和异常 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:09.808000             🧑  作者: Mango

代码示例1
def loan_emi(amount, duration, rate, down_payment=0):
    loan_amount = amount - down_payment
    try:
        emi = loan_amount * rate * ((1+rate)**duration) / (((1+rate)**duration)-1)
    except ZeroDivisionError:
        emi = loan_amount / duration
    emi = math.ceil(emi)
    return emi