Mark As Completed Discussion

Working with Files

Analyzing or working with data from a local file in a program is called file handling. Suppose you have student academic records in a file and want to calculate percentages of each student. Calculating it one by one in a file is a tiring task. This work would be easier if the file could be loaded to a program, and you could directly apply the operation on all the data in the file.

To work with files in Python, you need to open the file (within the program), perform an operation on it (read or write), and then close the file. Simple, right? Let's see how it looks in code.

JAVASCRIPT
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment