Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
If you should depend down a selected period of time, say for instance, when a token is about to run out, then a countdown timer can be helpful.
Place the next Python code in a file known as countdowntimer.py
import time
def countdown(t):
whereas t:
minutes, secs = divmod(t, 60)
timer = '{:02d}:{:02d}'.format(minutes, secs)
print(timer, finish="r")
time.sleep(1)
t -= 1
print('Countdown time has elapsed!!')
t = enter("Enter the time in seconds: ")
countdown(int(t))
Right here we additionally invoke say
which speaks out the textual content. That is solely native to some working programs.
Notice: If you happen to use MacOS, it will work out the field for you!
import time
import os
def countdown(t):
whereas t:
minutes, secs = divmod(t, 60)
timer = '{:02d}:{:02d}'.format(minutes, secs)
print(timer, finish="r")
time.sleep(1)
t -= 1
txt = 'Countdown time has elapsed!!'
print(txt)
os.system('say "'+txt+'"')
t = enter("Enter the time in seconds: ")
countdown(int(t))
python3 <path_to_file>/countdowntimer.py
If you happen to use bash
then do that:
echo "alias depend='python3 <path_to_file>/countdowntimer.py'" >> ~/.bash_profile
If you happen to use zsh
then do that:
echo "alias depend='python3 <path_to_file>/countdowntimer.py'" >> ~/.zshrc
Now when you’ve reloaded the terminal session by doing one of many following:
supply ~/.bash_profile
supply ~/.zshrc
You possibly can simply name depend
and the applying will begin.
Once you first run the applying, you possibly can specify the quantity of seconds to depend down from.
If you happen to enter 30
, then it can depend down for 30 seconds.
If you happen to enter 3600
(60seconds x 60minutes), then it can depend down for an hour.
and many others.