-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclock_code.py
More file actions
148 lines (141 loc) · 5.08 KB
/
clock_code.py
File metadata and controls
148 lines (141 loc) · 5.08 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import time
import sys
def clock():
form=int(input("1. 12-hour format or 2. 24-hour format [Enter 1/2]: "))
if form==1:
print("----------------------------")
while True:
t=time.strftime("%I:%M:%S %p",time.localtime())
print(f"\rCurrent Time: {t}",end='',flush=True)
time.sleep(1)
print("----------------------------")
elif form==2:
print("----------------------------")
while True:
t=time.strftime("%H:%M:%S %p",time.localtime())
print(f"\rCurrent Time: {t}",end='',flush=True)
time.sleep(1)
print("----------------------------")
else:
print("Invalid choice")
def timer(second):
while second!=-1:
m=second//60
s=second-(m*60)
print(f"\r {m:02d}:{s:02d} ",end='',flush=True)
time.sleep(1)
second-=1
def countdown_timer(sec):
label=input("Enter a label the countdown[Press Enter to skip]: ")
print("----------------------------")
print("Countdown Started!")
print("----------------------------")
if label=='':
print("Time left: ")
else:
print(f"{label} ends in: ")
timer(sec)
print("\n----------------------------")
print("Time's up!")
def pomodoro():
print("Default Setings: ")
print("1. Focus period: 25 min\n2. Break period: 5 min\n3. Rounds: 4\n4. Long break period(after each 4 rounds): 30 min")
print("----------------------------")
while True:
ch1=input("Change Settings(yes/no)? ")
if ch1=='yes':
print("----------------------------")
while True:
ch2=input("Which setting do you want to change(1-4)?[Press Enter to skip] ")
if ch2=='1':
f=int(input("Enter new Focus Period(min): "))
fp=f*60
print("----------------------------")
elif ch2=='2':
b=int(input("Enter new Break period(min): "))
bp=b*60
print("----------------------------")
elif ch2=='3':
r=int(input("Enter new number of rounds: "))
print("----------------------------")
elif ch2=='4':
l=int(input("Enter new Long break period(min): "))
lbp=l*60
print("----------------------------")
elif ch2=='':
break
else:
print("Invalid Input!")
print("----------------------------")
break
elif ch1=='no':
fp=1500
bp=300
r=4
lbp=1800
break
else:
print("Invalid Input!")
print("----------------------------")
while True:
ch3=input("Press Enter to Start Pomodoro ")
if ch3=='':
print("--------------------------------------")
c=0
while True:
while c<r:
print(f"---------------Round {c+1}----------------")
print("-----Focus-----")
timer(fp)
time.sleep(1)
print("----------------------------")
print("-----Break-----")
timer(bp)
time.sleep(1)
c+=1
print("--------------------------------------")
print("-----Break-----")
timer(lbp)
time.sleep(1)
break
else:
print("Invalid Input!")
#main program
print("--------------------------------------------------------")
print()
print(" TIME PROGRAM")
print(" Clock | Timer | Pomodoro")
print()
print("--------------------------------------------------------")
print("1. Digital clock\n2. Timer\n3. Pomodoro")
while True:
try:
ch=int(input("Enter your choice(1-3): "))
except ValueError:
print("Invalid Input!\n----------------------------")
else:
if ch==1:
print("-------------------------------------------------")
clock()
print("-------------------------------------------------")
break
elif ch==2:
print("----------------------------")
while True:
try:
seconds=int(input("Enter the seconds to count: "))
except ValueError:
print("Invalid Input!\n----------------------------")
else:
break
print("-------------------------------------------------")
countdown_timer(seconds)
print("-------------------------------------------------")
break
elif ch==3:
print("-------------------------------------------------")
pomodoro()
print("-------------------------------------------------")
break
else:
print("Invalid choice!\n----------------------------")