Six pages and a sidebar, each lecture step with its screenshot and what it taught; review record RC-008. Refs #14 Refs #15 Refs #16 Refs #17 Refs #18
799 B
799 B
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
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.
