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. When the time is exhausted, makes a beeping sound non-stop until the user exits the app.Counts down from the input value, and prints out the time left on the clock every second.The last character of the string entered would be used to determine its unit.Asks the user to enter a time duration in the form of a number with a unit of either seconds, minutes, or hours. ![]() ECX 30 Days of Code and Design Day 20 Task
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |