brendan-stanford

Countdown

Oct 20th, 2019
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #import libraries
  2. from time import sleep
  3.  
  4. #set countdown function to divide time in seconds by 60 to find minutes; modulo time by 60 to find leftover seconds, then sleep and print Game Over if t = 0
  5. def countdown(t):
  6. while t > 0:
  7. mins = str(int(t / 60))
  8. sec = str(t % 60)
  9. print("Minutes: " + mins + ", Seconds: " + sec)
  10. t = t - 1
  11. sleep(1)
  12. if t == 0:
  13. print("Game Over")
  14.  
  15. #start countdown
  16. countdown(5)
Add Comment
Please, Sign In to add comment