0% found this document useful (0 votes)
4 views

Python Timer

The document contains code for a countdown or countup timer program that allows the user to choose the type of timer and set the starting or ending number, then prints out a countdown or countup and sleeps for 1 second between each number before ending.

Uploaded by

eleemather
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Python Timer

The document contains code for a countdown or countup timer program that allows the user to choose the type of timer and set the starting or ending number, then prints out a countdown or countup and sleeps for 1 second between each number before ending.

Uploaded by

eleemather
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import time

z = input("Do you want a countdown timer or a countup timer? cd/cu : ")


if z == "cu" :
y = int(input("To what number would you like it to count up to ? "))
for x in range (0,y) :
print (1+x)
time.sleep (1) ;
# Clear screen for Unix/Linux/MacOS
print("\033c", end="")
# Clear screen for Windows
print("\033[H\033[J", end="")
print("Ended")
if z == "cd" :
y = int(input("To what number would you like it to count down from ? "))
for x in range (0,y) :
print (y-x)
time.sleep (1) ;
print("\033c", end="")
print("\033[H\033[J",end="")
print("Ended")

You might also like