Question: import os class FileHandler: def _ _ init _ _ ( self , filename ) : self.filename = filename def read _ file ( self
import os
class FileHandler:
def initself filename:
self.filename filename
def readfileself:
with openselffilename, r as file:
data file.read
return data
def writefileself data:
with openselffilename, w as file:
file.writedata
def deletefileself:
osremoveselffilename
def main:
filename inputEnter the filename:
filehandler FileHandlerfilename
while True:
action inputDo you want to Read, Write or Delete the file? RWD:
if action.lowerr:
printfilehandler.readfile
elif action.lowerw:
data inputEnter the data to write:
filehandler.writefiledata
elif action.lowerd:
filehandler.deletefile
printFile deleted successfully."
else:
printInvalid option. Please try again."
if namemain:
mEnsure that your report includes the following:
a Explanation of the algorithm used in the program.
b Discussion of coding best practices used in the program.
c Explanation of any issues encountered during development and how they were resolved.
d Any other relevant information.ain
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
