-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathExercise_5
48 lines (43 loc) · 1.6 KB
/
Exercise_5
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
# Health Management System
client_list = {1:"Harry", 2:"Rohan", 3:"Hammad"}
log_list = {1:"Exercise", 2:"Diet"}
def getdate():
import datetime
return datetime.datetime.now()
try:
print("Select Client Name:")
for key, value in client_list.items():
print("Press", key, "for", value,"\n", end="")
client_name = int(input())
print("Selected Client : ", client_list[client_name], "\n", end="")
print("Press 1 for Log")
print("Press 2 for Retrieve")
op = int(input())
if op is 1:
for key, value in log_list.items():
print("Press", key, "to log", value,"\n", end="")
log_name = int(input())
print("Selected Job : ", log_list[log_name])
f = open(client_list[client_name] + "_" + log_list[log_name] + ".txt", "a")
k = 'y'
while(k is not "n"):
print("Enter", log_list[log_name], "\n", end="")
mytext = input()
f.write("[ " + str(getdate()) + " ] : " + mytext + "\n")
k = input("ADD MORE ? y/n:")
continue
f.close()
elif op is 2:
for key, value in log_list.items():
print("Press", key, "to retrieve", value,"\n", end="")
log_name = int(input())
print(client_list[client_name], "-", log_list[log_name], "Report :","\n", end="")
f = open(client_list[client_name] + "_" + log_list[log_name] + ".txt", "rt")
contents = f.readlines()
for line in contents:
print(line, end="")
f.close()
else:
print("Invalid Input !!!")
except Exception as e:
print("Wrong Input !!!")