Skip to content

Commit

Permalink
Create Simple_Stop_Watch.py
Browse files Browse the repository at this point in the history
  • Loading branch information
CogitoKunal committed Oct 26, 2024
1 parent 045ec95 commit 5269c57
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Program's_Contributed_By_Contributors/Simple_Stop_Watch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import time

print('Press ENTER to begin, Press Ctrl + C to stop')
while True:
try:
input() #For ENTER
starttime = time.time()
print('Started')
except KeyboardInterrupt:
print('Stopped')
endtime = time.time()
print('Total Time:', round(endtime - starttime, 2),'secs')
break
# Press enter to start and stop the watch
"""
import time
print('Press Enter to begin, Press Enter again to stop')
if input()=='':
starttime = time.time()
print('Started')
while True:
val=input() #For ENTER
if val=='':
print('Stopped')
endtime = time.time()
print('Total Time:', round(endtime - starttime, 2),'secs')
break
"""

"""
Output:
Press Enter to begin, Press Enter again to stop
Started
Stopped
Total Time: 1.05 secs
"""

0 comments on commit 5269c57

Please sign in to comment.