The task is to create a "Health Management System." Suppose you are a fitness trainer and nutritionist. You have to deal with three clients, i.e., (Harry, Rohan, Hammad). For each client, you have to design their exercise and diet plan.
def getdate():
import datetime
return datetime.datetime.now()
You are advised to participate in solving this problem. This task helps you to become a good problem solver and enables you to accept the challenge and acquire new skills.
Keep supporting and stay up to date with codewithharry.
# 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
# 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()
harry bhai mai aap ko youtube mai bhi message kiya aur maine har aap ki website se bhi padh raha hu code ye raha hai def excercise(person): with open(person+'_excersie'+".txt",'a') as f: print("Prepare Excersie for ", person +":") excercise_Menu=input() p=str(getdate()) f.write(p+" : "+excercise_Menu+"\n") def diet(person): with open(person+"_diet"+".txt",'a') as f: print("Prepare diet for ", person +":") dietMenu=input() p=str(getdate()) f.write(p+" : "+dietMenu+"\n") def read(person): print("What you want to read :- Diet(press 1), Excersie(press 2):") readchoice=int(input()) if readchoice==1: f=open(person+"_diet"+".txt",'r') print(f.read()) f.close() else: f=open(person+"_excersie"+".txt",'r') print(f.read()) f.close() def getdate(): import datetime return datetime.datetime.now() print("Enter CLient Name :") client=input() print("what you want to log: Diet(press 1), Excersie(press 2) or Retrive the data of person(press 3)") choice=int(input()) if choice ==1: diet(client) elif choice== 3: read(client) else: excercise(client)
# Bhai badi mehnat se banaya hai please dekh lena, accha laga to reply zarur karna. #File names - Harryexe.txt, Rohanexe.txt, Hammadexe.txt, Harrydiet.txt,Rohandiet.txt,Hammaddiet.txt. print("#>>>>>Welcome to health management system<<<<<<#") while(True): def getdate(): import datetime return datetime.datetime.now() print("What is your client name?") print(" 1) 1 For Harry" "\n 2) 2 For Rohan" "\n 3) 3 For Hammad ") try: x = int(input("=>")) except ValueError: print("Invalid input! try again") continue print("What do you want to do with this profile ?") print(" 1) 1 For Lock something" "\n 2) 2 For View something") try: y = int(input("=>")) except ValueError: print("Invalid input! try again") continue print("What do you want to view/lock ?") print(" 1) 1 For View/lock Diet" "\n 2) 2 For View/lock Exercise") try: z = int(input("=>")) except ValueError: print("Invalid input! try again") continue if x == 1 and y == 1 and z == 1: Harry = open("Harrydiet.txt", "a") harrydiet = input("Enter the diet name.=>") Harry.write("[") Harry.write(str(getdate())) Harry.write("] => ") Harry.write(harrydiet) Harry.write(". \n") Harry.close() print("Locked succesfully...") print("Lock more (y/n) ?") kaka = input() if kaka == "y": print("Let's go!!!") continue if kaka == "n": print("Exiting") print("Bye") print(4 * "*") print(3 * "*") print(2 * "*") print("*") break elif x == 2 and y == 1 and z == 1: Rohan = open("Rohandiet.txt", "a") Rohandiet = input("Enter the diet name.=>") Rohan.write("[") Rohan.write(str(getdate())) Rohan.write("] => ") Rohan.write(Rohandiet) Rohan.write(". \n") Rohan.close() print("Locked succesfully...") print("Lock more (y/n) ?") kaka = input() if kaka == "y": print("Let's go!!!") continue if kaka == "n": print("Exiting") print("Bye") print(4 * "*") print(3 * "*") print(2 * "*") print("*") break elif x == 3 and y == 1 and z == 1: Hammad = open("Hammaddiet.txt", "a") Hammaddiet = input("Enter the diet name.=>") Hammad.write("[") Hammad.write(str(getdate())) Hammad.write("] => ") Hammad.write(Hammaddiet) Hammad.write(". \n") Hammad.close() print("Locked succesfully...") print("Lock more (y/n) ?") kaka = input() if kaka == "y": print("Let's go!!!") continue if kaka == "n": print("Exiting") print("Bye") print(4 * "*") print(3 * "*") print(2 * "*") print("*") break elif x == 1 and y == 1 and z == 2: Harrye = open("Harryexe.txt", "a") harryexe = input("Enter the exercise name.=>") Harrye.write("[") Harrye.write(str(getdate())) Harrye.write("] => ") Harrye.write(harryexe) Harrye.write(". \n") Harrye.close() print("Locked succesfully...") print("Lock more (y/n) ?") kaka = input() if kaka == "y": print("Let's go!!!") continue if kaka == "n": print("Exiting") print("Bye") print(4 * "*") print(3 * "*") print(2 * "*") print("*") break elif x == 2 and y == 1 and z == 2: Rohane = open("Harryexe.txt", "a") Rohanexe = input("Enter the exercise name.=>") Rohane.write("[") Rohane.write(str(getdate())) Rohane.write("] => ") Rohane.write(Rohanexe) Rohane.write(". \n") Rohane.close() print("Locked succesfully...") print("Lock more (y/n) ?") kaka = input() if kaka == "y": print("Let's go!!!") continue if kaka == "n": print("Exiting") print("Bye") print(4 * "*") print(3 * "*") print(2 * "*") print("*") break elif x == 3 and y == 1 and z == 2: Hammade = open("Hammadexe.txt", "a") Hammadexe = input("Enter the exercise name.=>") Hammade.write("[") Hammade.write(str(getdate())) Hammade.write("] => ") Hammade.write(Hammadexe) Hammade.write(". \n") Hammade.close() print("Locked succesfully...") print("Lock more (y/n) ?") kaka = input() if kaka == "y": print("Let's go!!!") continue if kaka == "n": print("Exiting") print("Bye") print(4 * "*") print(3 * "*") print(2 * "*") print("*") break elif x == 1 and y == 2 and z == 1: Reahardie = open("Harrydiet.txt") #k = int(input("Enter which line do you want to read? =>")) pop=Reahardie.read() print("*___________Diet info of Harry____________*") print("| Date & Time => Food Taken|") print(pop) print("___________________________________________") Reahardie.close() print("View more (y/n) ?") kaka = input() if kaka == "y": print("Let's go!!!") continue if kaka == "n": print("Exiting") print("Bye") print(4 * "*") print(3 * "*") print(2 * "*") print("*") break elif x == 1 and y == 2 and z == 2: Reaharexe = open("Harryexe.txt") #k = int(input("Enter which line do you want to read? =>")) bob=Reaharexe.read() print("*_______Exercise info of Harry____________*") print("| Date & Time => Exercise |") print(bob) print("___________________________________________") Reaharexe.close() print("view more (y/n) ?") kaka = input() if kaka == "y": print("Let's go!!!") continue if kaka == "n": print("Exiting") print("Bye") print(4 * "*") print(3 * "*") print(2 * "*") print("*") break elif x == 2 and y == 2 and z == 1: Rearohdie = open("Rohandiet.txt") #k = int(input("Enter which line do you want to read? =>")) knob=Rearohdie.read() print("*___________Diet info of Rohan____________*") print("| Date & Time => Food Taken|") print(knob) print("___________________________________________") Rearohdie.close() print("view more (y/n) ?") kaka = input() if kaka == "y": print("Let's go!!!") continue if kaka == "n": print("Exiting") print("Bye") print(4 * "*") print(3 * "*") print(2 * "*") print("*") break elif x == 2 and y == 2 and z == 2: Rearohexe = open("Rohanexe.txt") #k = int(input("Enter which line do you want to read? =>")) hip=Rearohexe.read() print("*_______Exercise info of Rohan____________*") print("| Date & Time => Exercise |") print(hip) print("___________________________________________") Rearohexe.close() print("view more (y/n) ?") kaka = input() if kaka == "y": print("Let's go!!!") continue if kaka == "n": print("Exiting") print("Bye") print(4 * "*") print(3 * "*") print(2 * "*") print("*") break elif x == 3 and y == 2 and z == 1: Reahamdie = open("Hammaddiet.txt") #k = int(input("Enter which line do you want to read? =>")) hop=Reahamdie.read() print("*___________Diet info of Hammad____________*") print("| Date & Time => Food Taken|") print(hop) print("___________________________________________") Reahamdie.close() print("view more (y/n) ?") kaka = input() if kaka == "y": print("Let's go!!!") continue if kaka == "n": print("Exiting") print("Bye") print(4 * "*") print(3 * "*") print(2 * "*") print("*") break elif x == 3 and y == 2 and z == 2: Reahamexe = open("Hammadexe.txt") #k = int(input("Enter which line do you want to read? =>")) tik=Reahamexe.read() print("*_______Exercise info of Hammad____________*") print("| Date & Time => Exercise |") print(tik) print("___________________________________________") Reahamexe.close() print("view more (y/n) ?") kaka = input() if kaka == "y": print("Let's go!!!") continue if kaka == "n": print("Exiting") print("Bye") print(4 * "*") print(3 * "*") print(2 * "*") print("*") break else: print("Invalid input ! try again") continue
No downloadable resources for this video. If you think you need anything, please post it in the QnA!
Any Course related announcements will be posted here