Elementary Level Python File Manager Project
Statement: Provide user an option to choose from three options:
- Read data from file
- Write data to a file
- Exit the program
Based on the choice, the user can read data from a file, he/she wants to. Write data to the file or exit from the program.
Get inputs on filename and data from the user. And try to make the program modular i.e. make separate files for utility functions.
To create a simple choice based program, you need to use a conditional statement, we have used if-else for you to easily understand. You can use others too.
We will ask the user for the file name and print its contents.
We will ask the user for data and file name, and then write content to the file, if the file is not present write will create a new file
Exit the program.
**Try to create the program yourself first and then refer to this code, your program can be more efficient than this one, as we have written this program so that everyone can easily understand.
Program for choice-based read-write in Python
Main.py
FileManager.py
Output:
File: file.txt (before)
File: file.txt (after)
need an explanation for this answer? contact us directly to get an explanation for this answer