询问用户几分钟,然后告诉他们几小时后的时间

Asking the user for minutes then telling them what it is in hours

询问用户几分钟。告诉他们那是几小时。我是 python 的新手,仍在尝试弄清楚一些基础知识,但无论我尝试什么都无济于事,所以请帮忙。

基本步骤:

# prompt for input and convert from str to int
minutes = int(input("minutes:" ))
# minutes: 135

# do the math
hours, minutes = divmod(minutes, 60)
# short-hand for
# hours = minutes // 60
# minutes = minutes % 60

# produce output of some kind
print(f"{hours}:{minutes}h")
# 2:15h

一些实用程序的文档: