-
Notifications
You must be signed in to change notification settings - Fork 25
/
alarm.py
73 lines (44 loc) · 1.33 KB
/
alarm.py
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import winsound, time, os, platform
def sound():
for i in range(2): # Number of repeats
for j in range(9): # Number of beeps
winsound.MessageBeep(-1) # Sound played
time.sleep(2) # How long between beeps
def alarm(n):
print()
print("Wait time:", n, "seconds.")
time.sleep(n) # Waits 'n' seconds before playing sound
sound()
def input_destinations(user_input):
if user_input == '1':
user_input = int(input("Enter the desired hours: "))
wait_time = (user_input * 60) * 60
alarm(wait_time)
elif user_input == '2':
user_input = int(input("Enter the desired minutes: "))
wait_time = user_input * 60
alarm(wait_time)
elif user_input == '3':
user_input = int(input("Enter the desired seconds: "))
wait_time = user_input
alarm(wait_time)
elif user_input == '4':
hours = int(input("Hours: "))
minutes = int(input("Minutes: "))
seconds = int(input("Seconds: "))
wait_time = ((hours*60)*60) + (minutes*60) + seconds
print(wait_time)
alarm(wait_time)
else:
try:
os.system('cls') # If OS is Windows
main()
except:
os.system('clear') # If OS is Linux or Mac
main()
def main():
print("What unit of time do you want to wait?\n (1) Hours\n (2) Minutes\n (3) Seconds\n (4) Combination")
main_input = input(": ")
input_destinations(main_input)
return;
main()