TIME MODULE IN PYTHON NOTES

import time
initial = time.time()
# it measures ticks as time since from epoch (a standard time taken independent from system generally from 1970)

print(initial)

for _ in range(0,100):
    print("Hello",_)
    
print(time.time() - initial)    # gives execution time of above for loop (in seconds)

# time functions
present2 = time.localtime(time.time())  # gives in tuple format

present = time.asctime(time.localtime(time.time())) #asctime makes the tuple format to a readable format

print(present)
print(f"This will be in tuple format = {present2}")

""" 
x = time.time() ---> gives ticks
y = time.localtime(x) ---> gives local view in tuple i.e. month year day etc.
time.asctime(y) ---> gives readable format 
"""




Comments

Popular Posts