Exercise 5: Health Management System

Code file as described in the video

# Health Management System
# 3 clients - Harry, Rohan and Hammad

def getdate():
    import datetime
    return datetime.datetime.now()

# Total 6 files
# write a function that when executed takes as input client name
# One more function to retrieve exercise or food for any client


  


Comments(2)

coder4web at 2019-06-23 09:30:09 says
def getdatetime(): import datetime return datetime.datetime.now() def callHealthManagementSystem(): print("Welcome to HMS\n"); operation = ( "Retrive","Write" ) user = ("Mukesh","Gautam","Praveen") log = ("Food_taken","Exercise_done") while True: n1 = input("What function you want to do\nPress 1 for Retrive, 2 For Write:\n") if int(n1) == 1 or int(n1) == 2: while True: n2 = input("Press 1 for Mukesh, 2 for Gautam, and 3 for Praveen\n") if int(n2) == 1 or int(n2) == 2 or int(n2) == 3: while True: n3 = input("Press 1 for Food, 2 for Exercise\n") if int(n3) == 1 or int(n3) == 2: filename = user[int(n2)-1]+"_"+log[int(n3)-1]+".txt" if int(n1) == 2: n4 = input("What " + log[int(n3) - 1] + " by " + user[int(n2) - 1]+":\n") with open(filename,"a+") as f: f.write("["+str(getdatetime())+"] "+ n4+"\n") print("details logged successfully") else: try: with open(filename,"rt") as f: filecontent = f.read() print (filecontent) except Exception as e: print(e) break else: print("Wrong choice try again") break else: print("Wrong user choose try again") break else: print("Wrong Operation call") callHealthManagementSystem()
Dhruva at 2019-06-23 09:30:09 says
# Made by Dhruva Shaw def getdate(): import datetime return datetime.datetime.now() def log(name,mode): t="" t = t+name mode = int(mode) if mode==1: t = t+"diet"+".txt" f = open(t,"x") f.close() with open(t,"r") as f: print("The previously logged diet are:") print(f.read()) with open(t,"a") as f: diet = input("Enter the diet, seperated by commas (',')\n") writing = str(getdate())+str(diet)+"\n" f.write(writing) print() print("Sucessfully written") print(str(getdate()),str(diet)) input() else: t = t+"exercise"+".txt" f = open(t,"x") f.close() with open(t,"r") as f: print("The previously logged exercise are:") print(f.read()) with open(t,"a") as f: exercise = input("Enter the exercise, seperated by commas (',')\n") writing = str(getdate())+str(exercise)+"\n" f.write(writing) print() print("Sucessfully written") print(str(getdate()),str(exercise)) input() a,b,d=0,0,0 c = "" def start(): print("Which client you want to enter log") print("Press 1 - for 'Harry'") print("Press 2 - for 'Rohan'") print("Press 3 - for 'Hammad'") print("If any worng input given it will open for 'Harry'") global a global b global c global d try: a = int(input()) if d!=1 or d!=2 or d!=3: a=1 except Exception as e: print("This was the error",e) print("Now opening for 'Harry'") print() a = 1 if a==1: c = "Harry" elif a==2: c = "Rohan" elif a==3: c = "Hammad" if a==1 or a==2 or a==3: print("What do you want to log in?") print("Press 1 - to log exercise") print("Press 2 - to log Diet") print("If nothing or wrong is entered then it will open for loging in diet") try: d = int(input()) if d==1 or d==2 or d==3: log(c,d) else: log(c,1) except Exception as e: print("This was the error",e) print("Now opening for 'loging in the diet of",c,"'") print() log(c,1) start()