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
22 lines
799 B
Markdown
22 lines
799 B
Markdown
# Step 1: the current time
|
|
|
|
**English** · [Dansk](Step-1-Current-Time-da) · [Bahasa Malaysia](Step-1-Current-Time-ms)
|
|
|
|
The starting code of the lecture prints the current time:
|
|
|
|
```python
|
|
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.
|