Source Code:
(back to article)
import time import datetime def convert_seconds(seconds): hours, seconds = divmod(seconds, 3600) minutes, seconds = divmod(seconds, 60) return f"{int(hours)} hours {int(minutes)} minutes {int(seconds)} seconds" start_time = time.time() i = 1 for i in range(1000000): i += 1 end_time = time.time() time_elapsed = end_time - start_time print("Time taken: ", time_elapsed) print(convert_seconds(time_elapsed))
Result:
Report an issue