请帮我弄清楚这段代码有什么问题;第一个功能正常 但第二个返回错误的数字。返回的第二个变量是自午夜以来经过的剩余分钟数。
def get_hours(s):
time=s/3600
return time
#The get_hour function returns how many hours have passed since midnight. The
# parameter is the time in seconds that has passed since midnight.
def get_minutes_remainder(s):
hours=get_hours(s)
minutes=s/60
a=round(hours)
b=a-hours
b=abs(b)
minutes=minutes*b
return minutes
答案 0 :(得分:1)
你需要使用地板而不是圆形(更不用说其他一些逻辑错误):
from math import floor
def get_minutes_remainder(s):
hours = get_hours(s)
whole_hours = floor(hours)
fractional_hours = hours - whole_hours
return fractional_hours * 60