Skip to content

Instantly share code, notes, and snippets.

@akarsh1995
Created July 26, 2020 15:43
Show Gist options
  • Select an option

  • Save akarsh1995/c1eaa1f743976b2b03dc6208db4f85a2 to your computer and use it in GitHub Desktop.

Select an option

Save akarsh1995/c1eaa1f743976b2b03dc6208db4f85a2 to your computer and use it in GitHub Desktop.
A stopwatch to keep the track of your activity right in the terminal/cmd.
import time
print('Press ENTER to begin, Press Ctrl + C to stop')
while True:
try:
input()
start_time = time.time()
print('Started')
while True:
print(
'Time Elapsed: ',
round(time.time() - start_time, 0),
'secs', end="\r"
)
time.sleep(1) # 1 second refresh delay
except KeyboardInterrupt:
print('Stopped')
endtime = time.time()
print('Total Time:', round(endtime - start_time, 2), 'secs')
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment