Search code examples
pythontimevariable-assignmentdifferenceseconds

Best timing method in Python?


I need it for my assignment ,its my first time with computer science .please anyone help with this one. question.****Type a return statement: "return " followed by the expression that performs the calculation described in the table above. (Remember that the return statement is used to give a value back to the caller of the function.) def seconds_difference(time_1, time_2):**** """ (number, number) -> number

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
"""

Solution

  • I wish you the best of luck in your class. Here's some help:

    def seconds_difference(first, second):
        return second - first
    
    print(seconds_difference(1800.0, 2160.0))
    

    You should really read about functions:

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