Project - Health Management System

 Source Code given below:-


from datetime import datetime

try:

    # function to return time

    def tstamp():

        time = str(datetime.now())

        return time


# taking dicision for input or display

    todo = input("Input or Display ? : ")

    ## user input block ##

    if todo.lower() == "input":

        name = input("Enter Your name : ")

        with open(name+".txt", "a") as f:  # creating file with user name

            eord = input("Choose \"1\" for Exercise and \"2\" for Diet : ") # eord - exer. or diet ,asking for type

            # of input !!!!!!!!!//


            f.write(tstamp()+"  ")  # writting time stamp with input

            if eord == "1":

                f.write(input("Enter Your Exercise :\n")+"\n")

            elif eord == "2":

                f.write(input("Enter Your Diet :\n")+"\n")

            else:

                raise BufferError  # creating error for wrong input (other than 1 and 2)

            print("Values Submitted.")  # satisfying massage for user



    ## Display Block ##

    elif todo.lower() == "display":

        name = input("Enter Your Name : ")  # asking name of existing user

        print(f"Logs of {name} given below : ")

        with open(name + ".txt") as f:  # opening user file

            log = f.read()

            print(log)


    ## wrong decision block (other than input or display) ##

    else:

        print(f"{todo} is not a command!")


except FileNotFoundError:

    print(f"\n No data exist for {name}")

except BufferError:

    print("Enter only 1 and 2.")


"""-----------------------------------------------------------------------------------------------------------------

How it works ?

Stores data for exercise or diet with timestamp for a given user

Also display the user logs if file exists

--------------------------------------------------------------------------------------------------------------------"""


Comments