Mryeetmemes

Cool Python Code that is a 1 Minute Timer

Apr 11th, 2024
567
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 = 60  # 1 minute
  13. countdown_timer(duration)
Advertisement
Add Comment
Please, Sign In to add comment