-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCountdown timer.py
More file actions
51 lines (42 loc) · 1.31 KB
/
Countdown timer.py
File metadata and controls
51 lines (42 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#countdown timer created by Joon Hao, in Visual Studio code with Python 3
#import modules
import time
#intro
print("Welcome to countdown timer!")
print()
print()
#start
while True:
print("Enter 'quit' to exit programme\nEnter 'countdown' to start countdown from specified time")
user_choice = input(":")
#user's choice
if user_choice == "quit" or user_choice == "Quit":
print("Closing programme...")
time.sleep(2)
print("Good bye!")
break
elif user_choice == "countdown" or user_choice == "Countdown":
time_sec = input("Time(sec): ")
print("Starting countdown")
print()
print(time_sec)
#negative not accepted message
if int(time_sec) < 0:
print("That's a negative! You can't turn back time!\nTry again")
print()
print()
else:
pass
#start countdown
while int(time_sec) > 0:
time_sec = int(time_sec) - 1
time.sleep(1)
print(time_sec)
#end message
if time_sec == 0:
print("Time's UP!!!")
else:
pass
#user error message
else:
print("Unknown input, please try again")