计算应收账款(debtors)
当我们以赊销方式出售商品时,赊销部分会在资产负债表的"Accounts Receivable"或"Debtors"(应收账款)科目下体现。例如,若 1 月发生赊销且回款期为 60 天,则该笔赊销会在 1 月记入"Debtors"科目,但要到 3 月才会回款(释放),以此类推。
在本练习中,我们将创建以下列表:
- 当月赊销额
credits,在本练习中为销售额的 60%。 - 应收账款总额
debtors,计算方式为:本月赊销额 + 上月赊销额 − 前两个月的赊销额(因为我们假设 2 个月前,也就是 60 天前的赊销,到本月会回收)。
我们已为变量 month 设置了索引。month 的初始值为 0。
本练习是课程的一部分
Python 金融预测
练习说明
创建空的
credits列表和空的debtors列表。完成
for循环:- 通过将销售额(变量
mvalue)乘以赊销比例(60%)计算当月赊销额。 - 如果
month大于 0,将本月赊销额加上上月赊销额,并将结果追加到debtors。 - 如果
month不大于 0,则将本月赊销额追加到debtors。
- 通过将销售额(变量
打印
debtors列表。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Create the list for sales, and empty lists for debtors and credits
sales = [500, 350, 700]
____ = []
____ = []
# Create the statement to append the calculated figures to the debtors and credits lists
for mvalue in sales:
credits.append(mvalue * ____)
if month > 0:
____.append(credits[____] + credits[month-1])
else:
____.append(credits[____])
month += 1
# Print the result
print("The ‘Debtors’ are {}.".format(_____))