英文:
How to convert minutes to hours in an Jupyter Notebook code?
问题
我试图在笔记本表达式中将330分钟转换为小时。它应该返回小时数和剩余的分钟。
它应该返回小时数和剩余的分钟。
提前感谢。
我正在使用Skills Network Labs框架,内核是Pyolite。
提前感谢。
英文:
For an example I am trying to convert 330 minutes into hours in a notebook expression. It should return the number of hours and the remaining as minutes.
It should return the number of hours and the remaining as minutes.
Thanks in advance.
I am using Skills Network Labs framework with Pyolite as the kernel.
Thanks in advance.
答案1
得分: 1
Modulo and floor division;
minutes = 330 % 60
hours = 330 // 60
There's a neater way with divmod
;
hours, minutes = divmod(330, 60)
英文:
Modulo and floor division;
minutes = 330 % 60
hours = 330 // 60
There's a neater way with divmod
;
hours, minutes = divmod(330, 60)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论