reading and writing files the path(constructor takes the path to create for example ' :/mydir(on windowsor '/users/user /mydiron mac or '/var/tempon linux etc you can then use several different methods on the path object to obtain information about the path such asexists(returns true of false depending on whether the path points to an existing file or directory is_dir(returns true if the path points to directory false if it references file false is also returned if the path does not exist is_file(returns true of the path points to fileit returns false if the path does not exist or the path references directory absolute( path object is considered absolute if it has both root and (if appropriatea drive is_absolute(returns boolean value indicating whether the path is absolute or not an example of using some of these methods is given belowfrom pathlib import path print('create path object for current directory' path('print(' :'pprint(' exists():' exists()print(' is_dir():' is_dir()print(' is_file():' is_file()print(' absolute():' absolute()sample output produced by this code snippet iscreate path object for current directory pp exists()true is_dir()true is_file()false absolute()/users/shared/workspaces/pycharm/pythonintro/textfiles there are also several methods on the path class that can be used to create and remove directories and files such asmkdir(is used to create directory path if it does not exist if the path already existsthen fileexistserror is raised rmdir(remove this directorythe directory must be empty otherwise an error will be raised