technical skills grow

Responsive Ads Here

Friday, September 4, 2020

Project in Python - Daily Routine Plane using file handling

 Learn python :Learn Python step by step

      


Program : Daily Routine Plane using file handling

from datetime import datetime
def getdate():
# datetime object containing current date and time
now = datetime.now()
# dd/mm/YY H:M:S
dt_string = now.strftime("%d/%m/%Y %H:%M:%S")
return dt_string

file = int(input("Read file press 1 or entry data press 2"))
person = input("Enter the person name")
if file == 1:
RF = open(person,"r")
p= RF.read()
print(p)
else:

c = int(input("Press 1 for Food and 2 for Exercise"))
if c == 1:
meal = input("Enter the meal")
# def food(meal):
f = open(person , "a")
f.write(str(str(getdate())) + " : " + "Meal- " + meal + "\n")
else:
# def exercise(ex):
ex = input("Enter the exercise name")
f = open(person , "a")
# f.write(ex)
f.write(str(str(getdate())) + " : " + "Ex- " + ex + "\n")
Output  

Read file press 1 or entry data press 21
Enter the person nameTarun
05/09/2020 00:56:44 : Roti
05/09/2020 00:59:35 : butter fly
05/09/2020 01:01:20 : Meal-Rice


 Learn python :Learn Python step by step

No comments:

Post a Comment

Powered by Blogger.

Labels

Contact Form

Name

Email *

Message *

Search This Blog

Blog Archive

Ad Code

Responsive Advertisement

Recent Posts