-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathcounter.py
More file actions
43 lines (36 loc) · 931 Bytes
/
counter.py
File metadata and controls
43 lines (36 loc) · 931 Bytes
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
import time
# countdown timer
def countdown(t):
while t: # while t > 0 for clarity
mins = t // 60
secs = t % 60
timer = '{:02d}:{:02d}'.format(mins, secs)
print(timer, end="\r") # overwrite previous line
time.sleep(1)
t -= 1
print('Blast Off!!!')
t = input("Enter the time in seconds: ")
countdown(int(t))
# pomodoro timer
def pomodoro():
print("Pomodoro starts now!")
for i in range(4):
t = 25*60
while t:
mins = t // 60
secs = t % 60
timer = '{:02d}:{:02d}'.format(mins, secs)
print(timer, end="\r") # overwrite previous line
time.sleep(1)
t -= 1
print("Break Time!!")
t = 5*60
while t:
mins = t // 60
secs = t % 60
timer = '{:02d}:{:02d}'.format(mins, secs)
print(timer, end="\r") # overwrite previous line
time.sleep(1)
t -= 1
print("Work Time!!")
pomodoro()