-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
045ec95
commit 5269c57
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
Program's_Contributed_By_Contributors/Simple_Stop_Watch.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
""" |