在Python中使find_monthly_savings函数返回金额除以一年中的月份数(十二个月)的正确方法是什么?

DeltaVibes

所以我的问题是我一直在努力解决学习Python的问题(它说这是针​​对初学者的,我已经完成了它,但是出于某种原因和计算原因,我在使用return函数时遇到了麻烦)。

我需要的find_monthly_savings功能,走量与多年函数来计算用户需要“每月”保存量,如果amount is < 0return None或者,如果years <= 0return None

def find_monthly_savings(amount, years): # used to divide the amount by years
  return amount / years

def amount(number): 
  if number < 0:
    return None

def years (months):
  if years < 0:
    return None


find_monthly_savings(amount = 360, years = 1)  #calling upon the dms function 
Kshitij saxena

干得好:

def find_monthly_savings(amount, years): # used to divide amount by years
  if amount < 0:
      return None
  if years <= 0:
      return None
  return amount / years

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

Related 相关文章

热门标签

归档