summaryrefslogtreecommitdiff
path: root/Chap15ProjStopWatch.py
diff options
context:
space:
mode:
Diffstat (limited to 'Chap15ProjStopWatch.py')
-rw-r--r--Chap15ProjStopWatch.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/Chap15ProjStopWatch.py b/Chap15ProjStopWatch.py
new file mode 100644
index 0000000..cf41409
--- /dev/null
+++ b/Chap15ProjStopWatch.py
@@ -0,0 +1,26 @@
+#! python3
+#! /usr/bin/env python3
+
+# Chapter 15 Project Super Stopwatch
+# Simple Stop Watch Program
+
+import time
+
+print('Press ENTER to begin. Afterwards, press ENTER to click the stopwatch.')
+print('Press CTRL-C to quit.')
+input()
+print('Started...')
+startTime = time.time()
+lastTime = startTime
+lapNum = 1
+
+try:
+ while True:
+ input()
+ lapTime = round(time.time() - lastTime, 2)
+ totalTime = round(time.time() - startTime, 2)
+ print('Lap #%s: %s (%s)' % (lapNum, totalTime, lapTime), end='')
+ lapNum += 1
+ lastTime = time.time()
+except KeyboardInterrupt:
+ print('\nDone.')