exception handler that prints suitable message and switches control to the start of the loop ("continues the loop"and the last if statement ensures that if the user doesn' enter any numbers at allthe summary isn' outputand division by zero is avoided file handling is fully covered in but right now we can create files by redirecting the print(functionsoutput from the console for examplec:\>test py results txt windows file association bug will cause the output of plain print(function calls made in the fictitious test py program to be written to the file results txt this syntax works in the windows console (usuallyand in unix consoles for windowswe must write :\python \python exe test py results txt if python is the machine' default python version or if the console exhibits the file association bugotherwiseassuming python is in the pathpython test py results txt should be sufficientif plain test py results txt doesn' work for unixes we must make the program executable (chmod + test pyand then invoke it by typing /test py unless the directory it is in happens to be in the pathin which case invoking it by typing test py is sufficient reading data can be achieved by redirecting file of data as input in an analogous way to redirecting output howeverif we used redirection with sum pythe program would fail this is because the input(function raises an exception if it receives an eof (end of filecharacter here is more robust version (sum pythat can accept input from the user typing at the keyboardor via file redirectionprint("type integerseach followed by enteror ^ or ^ to finish"total count while truetryline input(if linenumber int(linetotal +number count + except valueerror as errprint(errcontinue except eoferrorbreak if countprint("count ="count"total ="total"mean ="total count