# ANCHOR: = Main.py DocString """ Created by Jap-Slappa Date: 17th/Aug/2022 All My Countdown Timers v2.0 Utility Modules => All_Timers.py Module Summery: - v1.0 - Prints a numerical countdown, to the console. - Takes x1 positional arg (Int), to be used as the Total num to countdown from. - All functions use a fixed number to countdown from Date: 11th/Sept/2022 - v2.0 - This program is now FULLY WORKING!!.... - And can be run as a independent script. - Added: code control and execution, If run as Script - Changed one of the functions:.... any_countdownTimer() - Now can countdown with ANY number as it's Arg - Takes Any Number, Defaults to 5 - Now starting full DocStrings & proper Code Comments """ import time # ANCHOR: = countdownTimer_10sec # ?=============== (10 SECOND) TIMER COUNT DOWN ===============START # CountdownTimer Time In Seconds | ## User Input ## cd_timer_10 = 10 # CountdownTimer Func. || My_CD_Timers.countdownTimer_10sec(int(My_CD_Timers.cd_timer_10)) def countdownTimer_10sec(t: int): """countdownTimer_10sec() Function Summery: - Prints a numerical countdown, to the console. - Takes x1 positional arg (Int), to be used as the Total num to countdown from. - All functions use a fixed number to countdown from Args: t (int): Fixed numerical number, set to 10 """ print(f'==== {cd_timer_10} Seconds Countdown Timer ====') # Countdwn Timer while t: mins, secs = divmod(t, 60) timer = '{:02d}:{:02d}'.format(mins, secs) print(timer, end="\r") time.sleep(1) t -= 1 print('--------------------------------------------------------') # ANCHOR: = countdownTimer_5sec # ?=============== (5 SECOND) TIMER COUNT DOWN =======START # CountdownTimer Time In Seconds | ## User Input ## cd_timer_5 = 5 # CountdownTimer Func. || My_CD_Timers.countdownTimer_5sec(int(My_CD_Timers.cd_timer_5)) def countdownTimer_5sec(t: int): print(f'==== {cd_timer_5} Seconds Countdown Timer ====') # Countdwn Timer while t: mins, secs = divmod(t, 60) timer = '{:02d}:{:02d}'.format(mins, secs) print(timer, end="\r") time.sleep(1) t -= 1 print('--------------------------------------------------------') # ANCHOR: = countdownTimer_4sec # ?=============== (4 SECOND) TIMER COUNT DOWN ===============START # CountdownTimer Time In Seconds | ## User Input ## cd_timer_4 = 4 # CountdownTimer Func. || My_CD_Timers.countdownTimer_4sec(int(My_CD_Timers.cd_timer_4)) def countdownTimer_4sec(t: int): print(f'==== {cd_timer_4} Seconds Countdown Timer ====') # Countdwn Timer while t: mins, secs = divmod(t, 60) timer = '{:02d}:{:02d}'.format(mins, secs) print(timer, end="\r") time.sleep(1) t -= 1 print('--------------------------------------------------------') # ANCHOR: = countdownTimer_3sec # ?=============== (3 SECOND) TIMER COUNT DOWN ===============START # CountdownTimer Time In Seconds | ## User Input ## cd_timer_3 = 3 # CountdownTimer Func. || My_CD_Timers.countdownTimer_3sec(int(My_CD_Timers.cd_timer_3)) def countdownTimer_3sec(t: int): print(f'==== {cd_timer_3} Seconds Countdown Timer ====') # Countdwn Timer while t: mins, secs = divmod(t, 60) timer = '{:02d}:{:02d}'.format(mins, secs) print(timer, end="\r") time.sleep(1) t -= 1 print('--------------------------------------------------------') # ANCHOR: = countdownTimer_2sec # ?=============== (2 SECOND) TIMER COUNT DOWN ===============START # CountdownTimer Time In Seconds | ## User Input ## cd_timer_2 = 2 # CountdownTimer Func. || My_CD_Timers.countdownTimer_2sec(int(My_CD_Timers.cd_timer_2)) def countdownTimer_2sec(t: int): print(f'==== {cd_timer_2} Seconds Countdown Timer ====') # Countdwn Timer while t: mins, secs = divmod(t, 60) timer = '{:02d}:{:02d}'.format(mins, secs) print(timer, end="\r") time.sleep(1) t -= 1 print('--------------------------------------------------------') # ANCHOR: = Any_Countdown_Timer # todo: Main Countdown Timer # ?=============== (ANY) COUNTDOWN TIMER ===============START # CountdownTimer Time In Seconds | ## User Input ## # CountdownTimer: How To Call = My_CD_Timers.any_countdownTimer(3) # My 1st func with both.. Type Hint + Default Value def any_countdownTimer(cd_timer_1: int=5): """ any_countdownTimer => Utility Modules => All_Timers.py Function Summery: - Prints a numerical countdown, to the console. - Takes x1 positional arg (Int), to be used as the Total num to countdown from. - Args: cd_timer_1 (int, optional): Any Number. Defaults to 5. """ print() print(f'====== {cd_timer_1} Second Countdown Timer ======') # Countdwn Timer while cd_timer_1: mins, secs = divmod(cd_timer_1, 60) timer = '{:02d}:{:02d}'.format(mins, secs) print(timer, end="\r") time.sleep(1) cd_timer_1 -= 1 print('====== Countdown Timer Finished! ====== ') # print('--------------------------------------------------------') print() # ANCHOR: = __name__ = # My_Info.code_control_and_execution_name if __name__ == '__main__': # todo: TEST General Count Down Timer any_countdownTimer(3)