So i made a script and it works fine but it could be better.
The code will be written below, the purpose of the script is to make a beep sound when the timer runs out (that works) but i also want to show on the screen how many hours minutes and seconds it takes (and possibly days, weeks, months, years)
If you run this script it will make a beep in two hours but what it will show to the user is this:
2 hours, 120 minutes and 7199 seconds
1 hours, 119 minutes and 7198 seconds
So i want to make the script smarter and make it really work as a countdown clock. And make it say this:
2 hours, 0 minutes and 0 seconds
1 hours, 59 minutes and 59 seconds
etc...
like a real countdown clock, what my script just does is show the total time instead of calculating how many minutes of the hour are left and how many seconds of a minute are left.
import os,time,winsound
hours=2
minutes=0
sec=0
counter=hours*3600+minutes*60+sec
mins=int(counter/60)
hr=int(mins/60)
while counter > 0:
counter-=1
print('%i hours, ' %hr + '%i minutes ' %mins + 'and %s seconds' %counter)
mins=int(counter/60)
hr=int(mins/60)
time.sleep(1)
Freq = 1000 # Set Frequency To 2500 Hertz
Dur = 500 # Set Duration To 1000 ms == 1 second
winsound.Beep(Freq,Dur)