Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to create a countdown timer using python

# import the time module
import time
  
# define the countdown func.
def countdown(t):
    
    while t:
        mins, secs = divmod(t, 60)
        timer = '{:02d}:{:02d}'.format(mins, secs)
        print(timer, end="
")
        time.sleep(1)
        t -= 1
      
    print('Fire in the hole!!')
  
  
# input time in seconds
t = input("Enter the time in seconds: ")
  
# function call
countdown(int(t))
Comment

PREVIOUS NEXT
Code Example
Python :: 3d array in numpy 
Python :: using tqdm in for loop 
Python :: python import worldcloud 
Python :: python undefine variable 
Python :: ip regex python 
Python :: getting multiple selected value django 
Python :: how to plot corilation python 
Python :: python set comparison 
Python :: difference between compiler and interpreter 
Python :: how to enable execution time in jupyter lab 
Python :: difference between 2 timestamps pandas 
Python :: pandas sort 
Python :: how to delete a csv file in python 
Python :: python randomly chose user agent 
Python :: connection to server at "" (), port 5432 failed: timeout expired 
Python :: open file python 
Python :: what is python used for 
Python :: python csv to list 
Python :: spacy nlp load 
Python :: unique id python 
Python :: how to change a header in pandas 
Python :: current date to epoch python 
Python :: combine two dictionary adding values for common keys 
Python :: python fibonacci 
Python :: is power of python recursion 
Python :: find an element in pandas 
Python :: outliers removal pandas 
Python :: plotly heatmap with label 
Python :: append a zeros column numpy 
Python :: sqlite3 delete row python 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =