Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
当问题可以用简单运算符解决时,您必须避免使用递归,如下所示:
minute_input = int(input("minutes: ")) minute = minute_input % 60 hour = minute_input / 60 def day(hour): return hour / 24 print(day(hour), hour)
输出:
minutes: 60 0.041666666666666664 1.0
,如果您想将天数作为整数获取,则可以将最后的打印指令更改为:
print(int(day(hour)), hour)
You must avoid using recursion when the problem can be solved with simple operators as follows:
Output:
Also, if you want to get the days value as an integer, you can change the last print instruction to:
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
发布评论
评论(1)
当问题可以用简单运算符解决时,您必须避免使用递归,如下所示:
输出:
,如果您想将天数作为整数获取,则可以将最后的打印指令更改为:
You must avoid using recursion when the problem can be solved with simple operators as follows:
Output:
Also, if you want to get the days value as an integer, you can change the last print instruction to: