Back

Sanskar

Keen Learner and Exp... • 4d

Day 11 of learning python as a beginner. Topic: creating journal entry program using file I/O. I got a little sidleline from my original plan of editing my to-do list program and created an entirely new program this time for writing a daily journal. During the process I got inroduced to import function and to os and datetime. import is used to bring external code into the program so that I can use its function, classes and variable. os module allows python to interact with teh operating system (I used this to delete files). date time module as the name suggests work with the date and time. (I used date to record the journal entry and then time stamped it). I started with importing modules like datetime and os. Then I used striftime function to manuplate the presentation of date and time in DD/MM/YY and HH/MM/SS format. Then I used my usual if, elif and else ladder combined with the file I/O functions like "w" for write and "a" for appending the journal (for editing purpose) and then I used os module for deleting the files on user's command. As I got to know that python can delete my other files also and therefore I added a confirmation where the user has to enter file name twice to confirm deletion. I used open(f"{now.date()}.txt", "w") because I want to create and classify the file according to the date. "w" here stands for write. I also wrapped the whole thing is a while loop so that it can keep on repeating unless the user himself voluntarily stops it by typing done or nothing. I would really appreciate any suggestions to improve my code and here's my code a;ong with its result. I would have also shared the video of its functioning but I don't think the video format is currently supposted with images (do tell me if I am wrong).

Reply
1
10

More like this

Recommendations from Medial

Sanskar

Keen Learner and Exp... • 2d

Day 13 of learning python as a beginner. Topic: create a meeting booking program with classes. Yesterday I shared my banking program and many amazing people pointed out that I didn't used classes properly and the code looks more like script. So I o

See More
Reply
2
Image Description
Image Description

Anuj Wadhwa

Founder And CEO' of ... • 2m

How an entire OS is written like from the kernel to GUI and integration of system Controllable tools. like what languages are used and how much time it can take to write an entire OS from scratch.

5 Replies
5
Image Description

Sanskar

Keen Learner and Exp... • 5d

Day 10 of learning python as a beginner. Topic: File I/O You guys remeber I once created a to-do list (most probably on day 7)? many amazing people suggested that I should also put a history of tasks. At that time I was not aware about the File I/O

See More
2 Replies
3

Aryan patil

 • 

Monkey Ads • 1y

Antler Residency program Bangalore last date to apply 2 August 2024 Till mid of night

Reply
3
4
Image Description
Image Description

Ayush Maurya

AI Pioneer • 7m

What's the best AI agents you have used till date and how has it helped you ?

4 Replies
5
Image Description
Image Description

Somen Das

Senior developer | b... • 1y

SSHedit SSHedit is a powerful tool that connects to your SSH server using a .pem file or password authentication. It automatically copies the entire file structure to your local machine with the current date, ensuring version control and backups. Add

See More
4 Replies
1
4
Image Description

Suman solopreneur

Exploring peace of m... • 5m

the messy 10 journal book my mine lit in dust in my store room , so here is the solution, zenith a fully developed journal app , analyse your emotion and chat with your journal , no matter how old , and also you can take easily travel back to your m

See More
2 Replies
5

Dr Bappa Dittya Saha

We're gonna extinct ... • 5m

Niket Raj Dwivedi Please add date tracker for Grant, incubator program and Event list. This will increase the usability of the Tracker. Since users are paying for this, I think they should be able to track deadlines for the applications from the ap

See More
Reply
5

Download the medial app to read full posts, comements and news.