Python 中的最佳计时方法?

Best timing method in Python?

我的作业需要它,这是我第一次接触计算机科学。请任何人帮助解决这个问题。 问题。****键入 return 语句:"return " 后跟执行上面 table 中描述的计算的表达式。 (请记住,return 语句用于将值返回给函数的调用者。) def seconds_difference(time_1, time_2):**** """ (数字, 数字) -> 数字

Return the number of seconds later that a time in seconds

time_2 is than a time in seconds time_1.

>>> seconds_difference(1800.0, 3600.0)
1800.0
>>> seconds_difference(1800.0, 3600.0)
-1800.0
>>> seconds_difference(1800.0, 2160.0)
360.0
>>> seconds_difference(1800.0, 1800.0)
0.0
"""

祝你class好运。这里有一些帮助:

def seconds_difference(first, second):
    return second - first

print(seconds_difference(1800.0, 2160.0))

你真的应该阅读有关函数的内容:

http://anh.cs.luc.edu/python/hands-on/3.1/handsonHtml/functions.html