1
Step 1 Current Time
Tirsvad edited this page 2026-11-06 06:49:12 +01:00

Step 1: the current time

English · Dansk · Bahasa Malaysia

The starting code of the lecture prints the current time:

import time

print(time.time())  # seconds since Jan 1st, 1970

Step 1: the current time

Run it with python -m speed_calc.lecture_steps 1. Run it again a little later and the number is larger.

What we gained

  • time.time() returns the seconds since January 1st, 1970 as a float.
  • The difference between two readings is a duration in seconds: second run minus first run.
  • That difference is all a timer needs. The next steps put it inside a decorator.