存款贷款利率计算

错误解决:Type 'str' doesn't have excpected attribute '_sub_' less....This inspection detects type erros in function call expression. Due to dynamic and duck typing, this is possible in a limited but useful number of cases. Types of function paraments can be specified in docstrings or in Python 3 function annotations.

这个错误的原因是输入的数据是str字符串行,我们需要把输入的数据换成对应的数据类型。

存款贷款利率计算代码

import numpy as np

#存款利率采用复利计算,上个月的利率纳入下一个月的本金计算再下一个月的利率,第一个月不计算利率,一个月计算一次利率
def Bankrate(money,rate,moth):
    money2=money
    money1 = money * (1 + rate / 12)
    for i in range(moth-1):
        newmoney = money * (1 + rate / 1200) + money1
        money = newmoney
    print("每月存款",money2,"元")
    print(moth,"月后")
    print("存款总额",money,"元")
    #return money

#采用终值计算每个月应支付多少
def SumGeometric(bmoney,brate,bmoth):#公比、次方
    brate = brate / 12
    a = 1 + brate
    am=np.power(a,bmoth)
    gsum=am*(a-1)/(am-1)
    everymothmoney=bmoney*gsum
    print("分期",bmoth, "月付款")
    print( "每月付款", everymothmoney, "元")
    print("最后总共付款->",everymothmoney*bmoth,"元")
    #return everymothmoney

if __name__=="__main__":
    deposit="存款"
    loans="贷款"
    inwords=input("存款或者贷款计算选择")
    if (inwords==deposit):
        money=input("请输入每月存款金额:")
        moth=input("请输入存款几个月:")
        rate=input("存款年利率:")
        money=int(money)
        moth=int(moth)
        rate=float(rate)
        Bankrate(money, rate, moth)
    elif(inwords==loans):
        bmoney=input("请输入贷款金额:")
        bmoth=input("请输入分期(月)返款:")
        brate=input("贷款年利率:")
        bmoney=int(bmoney)
        bmoth=int(bmoth)
        brate=float(brate)
        SumGeometric(bmoney, brate, bmoth)
    else:
        print("请重新输入选择")

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值