Created
January 17, 2021 04:36
-
-
Save Jzarecta/ba3746bdb63fbdb1552aabc023c56f8f to your computer and use it in GitHub Desktop.
Un programa de cronometro
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
#! /usr/bin/python3 | |
# stopwatch.py - Un programa de cronometro | |
import time | |
print('Presiona ENTER para iniciar. Despues, presiona ENTER para hacer "clic" \ | |
al stopwatch. Presiona Ctrl-C para salir') | |
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("\nHecho.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment