Account
Categories

Time Module


Definition:

It is a module from the Python Standard Library used to manage and control time in Python programs.

It is used to create time delays, control timing, and measure how long a program takes to run.

Now you will clearly understand the code logic with the help of the flowchart.

Time Module Flowchart :

Start
↓
You write program and import time module
import time
↓
Python loads time module
↓
time module controls time in program
↓
print("Start")
↓
time.sleep(5)
↓
Program waits for 5 seconds
↓
print("End")
↓
Result shown
Start → (wait 5 seconds) → End
↓
End

Syntax:


import time

Example:


import time

print("Start")
time.sleep(5)
print("End")

Output:

Exercise

Use time module to print Start, wait for 5 seconds and then print End using Python.