how to countdown in python code example

Example 1: how to make a minute counter in python

counter = 1
print(counter)
import time
while True:
    time.sleep(60)
    counter += 1
    print(counter)
#this adds one to the counter every 60 seconds

Example 2: python countdown

import tkinter as tk


class ExampleApp(tk.Tk):
    def __init__(self):
        tk.Tk.__init__(self)
        self.label = tk.Label(self, text="", width=10)
        self.label.pack()
        self.remaining = 0
        self.countdown(10) 

    def countdown(self, remaining = None):
        if remaining is not None:
            self.remaining = remaining

        if self.remaining <= 0:
            self.label.configure(text="time's up!")
        else:
            self.label.configure(text="%d" % self.remaining)
            self.remaining = self.remaining - 1
            self.after(1000, self.countdown)

if __name__ == "__main__":
    app = ExampleApp()
    app.mainloop()

Example 3: how to make a timer in python

#Timer in python
#pip install playsound
import time
import playsound

question = int(input('How many seconds to wait: '))
time.sleep(question)

playsound.playsound('Hello.mp3')