功能使数字低于一定数量
我有一个函数,其中我获得了2个数字并添加75个功能,我不希望结果数超过275,是否有一个可以为我执行此操作的python函数,代码如下,
def newnumber(num1,num2):
numbers = num1+num2+75
if numbers >275:
numbers = numbers - 275;
else:
numbers
return numbers
上面的代码只有一次,我希望它有点循环,或者如果有任何可以做到这一点的python内置功能,它将很有帮助
I have a function in which i get 2 numbers and add 75 to it, i dont want the resultant number to exceed 275, is there a python function that can do this for me, the code is like below,
def newnumber(num1,num2):
numbers = num1+num2+75
if numbers >275:
numbers = numbers - 275;
else:
numbers
return numbers
Above code just does it once, i want it sort of looped or if there is any python builtin function that can do this, it will be helpful
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试
mod
如果要在
数字
或275
之间选择较小的,则可以使用min
You can try
mod
If you want to select the smaller one between
numbers
or275
, you can usemin
您是说循环时使用
吗?
Did you mean to use a
while
loop?