-
Notifications
You must be signed in to change notification settings - Fork 0
/
excercise5.py
65 lines (62 loc) · 1.96 KB
/
excercise5.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
def datalog(a) :
"""Function to lof data for users in file"""
print("What data you would like to log for "+a)
print("\n 1.Press 1 for Diet \n 2.Press 2 for excercise")
choice=int(input())
if(choice==1) :
f=open(a+"_diet.txt","a")
val=input('type the diet for user here \n')
f.write(str(getdate())+ val+"\n")
f.close()
elif (choice ==2) :
f = open(a+ "_excercise.txt", "a")
val = input('type the excercise for user here \n')
f.write(str(getdate()) + val + "\n")
f.close()
else:
print("wrong choice !")
def getdate():
"""Function to retreive current time and date"""
import datetime
return datetime.datetime.now()
def datartr(b) :
"""Function to retreive data for users in file"""
print("What data you want to see ? \n 1. Press 1 for Diet \n 2. Press 2 for excercise")
rchoice= int(input())
if (rchoice==1) :
f=open(b+"_diet.txt","rt")
content = f.read()
print(content)
f.close()
elif (rchoice==2) :
f = open(b + "_excercise.txt", "rt")
content = f.read()
print(content)
f.close()
#Main Program :
i='y'
while (i is not 'n'):
print("Please enter the user for which you want to log the data:\n 1.Press 1 for Harry \n 2.Press 2 for Hamaad \n 3.Press 3 for Rohan")
usr=int(input())
if (usr==1):
datalog('Harry')
elif (usr==2) :
datalog('Hamaad')
elif (usr==3) :
datalog('Rohan')
else :
print("Wrong choice !")
print("Your data has been logged !")
print("Please enter the user for which you want to retreive the data:\n 1.Press 1 for Harry \n 2.Press 2 for Hamaad \n 3.Press 3 for Rohan")
rtr=int(input())
if (rtr==1):
datartr('Harry')
elif (rtr==2) :
datartr('Hamaad')
elif (rtr==3) :
datartr('Rohan')
else :
print("Wrong choice !!")
print("Do you wish to continue?y/n")
i=input()
continue