Skip to content

Instantly share code, notes, and snippets.

@Jzarecta
Created January 17, 2021 04:36
Show Gist options
  • Save Jzarecta/ba3746bdb63fbdb1552aabc023c56f8f to your computer and use it in GitHub Desktop.
Save Jzarecta/ba3746bdb63fbdb1552aabc023c56f8f to your computer and use it in GitHub Desktop.
Un programa de cronometro
#! /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