目录:
Mortgage | Stand for |
---|---|
PMT | Payment |
PV | Present Value |
FV | Future Value |
完成这个函数对我这种学渣来说最困难的是公式,于是我直接上网找来了现成的
def pmt(rate, nper, pv):
num = rate*(1+rate)**nper/((1+rate)**nper -1)
payment = pv*num
print (round(payment, 2))
# pmt(0.1, 10, 500000)
Depreciation | Stand for |
---|---|
SLN | Straight line depreciation |
SYD | Sum of years digits |
DB | Declining balance method |
def SLN(cost, salvage, nper):
depreciation = (cost - salvage)/nper
print (round(depreciation, 2))
# SLN(500000, 100000, 4)
def SYD(cost, life, period, salvage = 0):
total = 0
for i in range(life + 1):
total += i
numerator = life - (period -1)
depreciation = (cost-salvage)*(numerator/total)
print (round(depreciation, 2))
# SYD(500000, 3, 1)
def DB(rate, cost, life, period, salvage = 0):
dep = cost - salvage
if period > life:
print ('折旧年限太小')
sys.exit()
elif period == life:
for i in range(period - 1):
dep -= dep*rate
depreciation = dep
print (round(depreciation, 2))
sys.exit()
for i in range(period):
dep -= dep*rate
depreciation = dep/9
print (round(depreciation, 2))
# DB(0.1, 500000, 2, 2)
string method |
---|
LEFT |
RIGHT |
MID |
def LEFT(text, num_charc):
container = []
for i in range(num_charc):
container.append(text[i])
out = ''.join(container)
print (out)
# LEFT('1233', 2)
申明
编程超级新手,肯定有很多不完善,包括代码可能显得有些冗杂。如果你有任何的建议,可以告诉我,谢谢你 ^_^
代码中没有太多的解释,如果你也是和我一样的新手,就多查查官方的documentation.
2024 - 快车库 - 我的知识库 重庆启连科技有限公司 渝ICP备16002641号-10
企客连连 表单助手 企服开发 榜单123