![]() You would notice the winsound module is commented that is because the bell character (‘\a’) did not work on my Windows PC, so I had to use the winsound module, but the bell character worked on Replit, but not the winsound module so, I have left it there should incase the bell characters fails to work, the winsound can be used. Print( 'Invalid input! Only integers are allowed.')įirst, we import the time, datetime, and winsound modules. Secs = input( "Enter the time in seconds: ")Ĭountdown(int(hours), int(minutes), int(secs)) Minutes = input( "Enter the time in minutes: ") Hours = input( "Enter the time in hours: ") Total_seconds = total_seconds - 1 # The timer continually beeps for the next 45 seconds Timer = datetime.timedelta(seconds=total_seconds) ![]() # Timer represents time left on countdown # While loop that checks if total_seconds reaches zero # If not zero, decrement total time by one second while total_seconds >= 0: Total_seconds = hrs * 3600 mins * 60 sec ![]() import time # For sleep import datetime # For timedelta # import winsound # For Beep on Windows OS # Countdown timer function def countdown( hrs, mins, sec): """Counts down time and gives off beeps when the time inputted elapse""" # Calculate the total number of seconds It would be explained in bits throughout this article. Hint: A "beeping sound" can be achieved using the "bell character", or any library of your choice.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |