Exercise 5 Health Management System


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


# 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

# Code:

import datetime
def gettime():
return datetime.datetime.now()
def take(k):
if k==1:
c=int(input("Dear Client\n"
"Pls Enter 1 for Excersise and 2 for Food\n"))
if(c==1):
value=input("Type here\n")
with open("Harry Exercises.txt","a") as op:
op.write(str([str(gettime())])+": "+value+"\n")
print("Successfully written")
elif(c==2):
value = input("type here\n")
with open("Harry Food.txt", "a") as op:
op.write(str([str(gettime())]) + ": " + value + "\n")
print("Successfully written")
elif(k==2):
c = int(input("Enter 1 for excersise and 2 for food\n"))
if (c == 1):
value = input("Type here\n")
with open("Rohan Exercises.txt", "a") as op:
op.write(str([str(gettime())]) + ": " + value + "\n")
print("Successfully written")
elif (c == 2):
value = input("Type here\n")
with open("Rohan Food.txt", "a") as op:
op.write(str([str(gettime())]) + ": " + value + "\n")
print("Successfully written")
elif(k==3):
c = int(input("Enter 1 for excersise and 2 for food\n"))
if (c == 1):
value = input("Type here\n")
with open("Hammad Exercises.txt", "a") as op:
op.write(str([str(gettime())]) + ": " + value + "\n")
print("Successfully Written")
elif (c == 2):
value = input("Type here\n")
with open("Hammad Food.txt", "a") as op:
op.write(str([str(gettime())]) + ": " + value + "\n")
print("Successfully written")
else:
print("Please enter Proper input\n"
"That is Kindly Press 1 For Rohan, 2 For Harry And 3 For Hammad")
def retrieve(k):
if k==1:
c=int(input("Enter 1 for excersise and 2 for food\n"))
if(c==1):
with open("Harry Exercises.txt") as op:
for i in op:
print(i,end="")
elif(c==2):
with open("Harry Food.txt") as op:
for i in op:
print(i, end="")
elif(k==2):
c = int(input("Enter 1 for excersise and 2 for food\n"))
if (c == 1):
with open("Rohan Exercises.txt") as op:
for i in op:
print(i, end="")
elif (c == 2):
with open("Rohan Food.txt") as op:
for i in op:
print(i, end="")
elif(k==3):
c = int(input("Enter 1 for excersise and 2 for food\n"))
if (c == 1):
with open("Hammad Exercises.txt") as op:
for i in op:
print(i, end="")
elif (c == 2):
with open("Hammad Food.txt") as op:
for i in op:
print(i, end="")
else:
print("Please enter valid input\n"
"That is Kindly Press 1 For Rohan, 2 For Harry And 3 For Hammad")
print("Health Management System:\n"
"Hello Dear Client")
a=int(input("Press 1 for Log the value and 2 for Retrieve\n"))

if a==1:
b = int(input("Press 1 for Harry 2 for Rohan 3 for Hammad\n"))
take(b)
else:
b = int(input("Press 1 for Harry 2 for Rohan 3 for Hammad\n"))
retrieve(b)

Comments

Popular posts from this blog

Pickle Module

Python File IO Basics