Mryeetmemes

Cool python code that is a 10 minute timer

Apr 11th, 2024
621
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | Software | 0 0
  1. import time
  2.  
  3. def countdown_timer(duration):
  4.     while duration > 0:
  5.         mins, secs = divmod(duration, 60)
  6.         timer_display = '{:02d}:{:02d}'.format(mins, secs)
  7.         print(timer_display, end='\r')
  8.         time.sleep(1)
  9.         duration -= 1
  10.     print("Timer complete!")
  11.  
  12. duration = 10 * 60  # 10 minutes
  13. countdown_timer(duration)
Advertisement
Add Comment
Please, Sign In to add comment