首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Python代码,用于计算每月增加10%的数字在一段时间内的增加

Python代码,用于计算每月增加10%的数字在一段时间内的增加
EN

Stack Overflow用户
提问于 2020-04-06 19:05:45
回答 1查看 150关注 0票数 0

我正在尝试获得选定月份期间的百分比增长,.i似乎无法掌握如何利用当前月值来计算新月份并将所有月份相加。

代码语言:javascript
复制
NOC  = int(input('Please enter the number of chickens : '))
MONTHS = int(input('Please enter the number of months for the estimate : '))
FCE = NOC*10*MONTHS/100

if NOC == '' and MONTHS =='' :
    print('please Enter a value for month and year')


else:
    print('Your Result',FCE)
EN

回答 1

Stack Overflow用户

发布于 2020-04-06 19:30:40

如果您正在寻找复合增长,那么您需要迭代每个月,并使用最近几个月的值来增加

代码语言:javascript
复制
NOC  = int(input('Please enter the number of chickens : '))

MONTHS = int(input('Please enter the number of months for the estimate : ')) 

for month in range(0, MONTHS):
   NOC = NOC + (NOC*0.1)

print(NOC)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61058351

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档