如何在Jupyter Notebook代码中将分钟转换为小时?

huangapple go评论56阅读模式
英文:

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)

huangapple
  • 本文由 发表于 2023年6月21日 22:59:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/76524673.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定