-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathex7_healthy_programmer.py
49 lines (41 loc) · 1.49 KB
/
ex7_healthy_programmer.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
from pygame import mixer
from datetime import datetime
import time
def music_player(file): # while using loop a second parameter stopper will be given
mixer.init()
mixer.music.load(file)
mixer.music.play()
# while True:
# a = input("Enter stop to pause the music\n")
# if stopper == a:
# mixer.music.stop()
# break
# OR CAN BE DONE THE FOLLOWING WAY TOO AS GIVEN BELOW WITHOUT USING LOOP AS IT WILL WAIT TILL THE INPUT IS NOT GIVEN
input("Enter any key to pause the music\n")
mixer.music.stop()
def eye_record(msg):
with open('eyes.txt',"a") as f:
f.write(f"{msg} {datetime.now()}\n")
def water_record(msg):
with open('water.txt','a') as f:
f.write(f"{msg} {datetime.now()}\n")
def exercise_record(msg):
with open('physical_exercise.txt','a') as f:
f.write(f"{msg} {datetime.now()}\n")
if __name__ == '__main__':
eye_time = time.time()
water_time = time.time()
exer_time = time.time()
while True:
if time.time()-eye_time > 1800:
music_player('eyes.mp3')
eye_record('did eye exercise at')
eye_time = time.time()
if time.time()-water_time > 2400:
music_player('water.mp3')
water_record('drank water at')
water_time = time.time()
if time.time()-exer_time > 2700:
music_player('physical.mp3')
exercise_record('did the physical exercise at')
exer_time = time.time()