From 75a42ec54dbf721caa659ddf02c1f46fc2cb4bef Mon Sep 17 00:00:00 2001 From: mlot Date: Fri, 6 Jun 2025 13:40:57 -0400 Subject: initial commit for archiving --- Chap15ProjStopWatch.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Chap15ProjStopWatch.py (limited to 'Chap15ProjStopWatch.py') 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.') -- cgit