From d8261582498d0741dee5a078cbcc5f5a5483a914 Mon Sep 17 00:00:00 2001 From: Iamabitch <114508685+Iamabitch@users.noreply.github.com> Date: Sat, 1 Oct 2022 05:44:50 +0530 Subject: [PATCH] Create CountdownTimer.py --- Basic Scripts/CountdownTimer.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Basic Scripts/CountdownTimer.py diff --git a/Basic Scripts/CountdownTimer.py b/Basic Scripts/CountdownTimer.py new file mode 100644 index 0000000..c80b695 --- /dev/null +++ b/Basic Scripts/CountdownTimer.py @@ -0,0 +1,27 @@ +import time + +# The countdown function is defined below + +def countdown(t): + +while t: + +mins, secs = divmod(t, 60) + +timer = '{:02d}:{:02d}'.format(mins, secs) + +print(timer, end="\r") + +time.sleep(1) + +t -= 1 + +print('Lift off!') + +# Ask the user to enter the countdown period in seconds + +t = input("Enter the time in seconds: ") + +# function call + +countdown(int(t))