programs with the skills you'll learn in this you'll make your programs more applicableusableand stable reading from file an incredible amount of data is available in text files text files can contain weather datatraffic datasocioeconomic dataliterary worksand more reading from file is particularly useful in data analysis applicationsbut it' also applicable to any situation in which you want to analyze or modify information stored in file for exampleyou can write program that reads in the contents of text file and rewrites the file with formatting that allows browser to display it when you want to work with the information in text filethe first step is to read the file into memory you can read the entire contents of fileor you can work through the file one line at time reading an entire file to beginwe need file with few lines of text in it let' start with file that contains pi to decimal places with decimal places per linepi_digits txt to try the following examples yourselfyou can enter these lines in an editor and save the file as pi_digits txtor you can download the file from the book' resources through the file in the same directory where you'll store this programs here' program that opens this filereads itand prints the contents of the file to the screenfile_reader py with open('pi_digits txt'as file_objectcontents file_object read(print(contentsthe first line of this program has lot going on let' start by looking at the open(function to do any work with fileeven just printing its contentsyou first need to open the file to access it the open(function needs one argumentthe name of the file you want to open python looks for this file in the directory where the program that' currently being executed is stored in this examplefile_reader py is currently runningso python looks for pi_digits txt in the directory where file_reader py is stored the open(function returns an object representing the file hereopen('pi_digits txt'returns an object representing pi_digits txt python stores this object in file_objectwhich we'll work with later in the program the keyword with closes the file once access to it is no longer needed notice how we call open(in this program but not close(you could open