How to Measure Time in Python

Python is an easy-to-read, free, interpretive programming language that contains numerous libraries and modules. You can use these modules to automate many tedious programming tasks. For example, use Python's Time module to measure how much time has passed between two dates.

Instructions

    • 1

      Open your Python editor.

    • 2

      Type:

      import time;

      tickTock = time.time()

      print "Number of seconds since 12:00am, May 28, 2011:", tickTock

    • 3

      Press "Enter." Python returns:

      "Number of seconds since 12:00am, May 28, 2011: 1307096391.56"

      In this example, you import the time module and Python calculates the amount of seconds in floating point format that has passed between 12:00am on May 28, 2011 to the current time on June 3, 2011.

Related Searches:

References

Comments

You May Also Like

Related Ads

Featured