Data files come in many different formats
There are many types of files, such as text files, audio files, video files, and various document formats used by word processors and presentation software. Text files contain only human-readable characters like letters, digits, and punctuation. Other file types often include binary data (binary files) or special formatting specific to their application. To work with such files, you need a program that understands the file’s format specification.
Try opening an older Microsoft PowerPoint (ppt) file in a text editor, such as Apple TextEdit, Microsoft Notepad, or one of the many Linux text editors (vi, emacs, gedit). Scroll through it; you’ll see what looks like gibberish or random characters:

What you’re seeing is binary data and markup information not meant for human reading: internal formatting instructions, document structure, line art, embedded images, metadata (such as creation and modification dates, author, and edit history), and more. Without Microsoft PowerPoint or a compatible program, ppt files cannot be adequately interpreted or displayed.
Away from Binary, Towards Text | |
|---|---|
| | Newer Microsoft Office files (pptx, docx, and xlsx) use a format based on ZIP-compressed folders of XML files. While this format is more transparent than the older binary ppt format, it’s still difficult to interpret without knowing the internal structure. You’ll still need PowerPoint (or a compatible app) to view the content as originally intended. This transition reflects a broader trend in software toward using text-based formats (like XML and JSON), which are easier to inspect, edit, and process with other tools. |
On the contrary, text files contain only human-readable characters. You can open a text file in any text editor and read and modify it.
Like any other container (a string or a list), a file can be empty, containing no data at all. Such a file typically has a size of 0 bytes. However, every file also has associated metadata maintained by the operating system, including information like its name, permissions, timestamps, and location on disk. This metadata exists even when the file’s contents are empty.
The Python programs you have been writing are text files. By themselves, they are only characters in a file. Combined with a Python interpreter, these Python text files are robust; you can express a powerful algorithm following Python’s syntax rules, and the interpreter will follow your instructions.
This power stems from applications that can process text files written in a specific syntax. Web browsers read and process HTML files, spreadsheets read and process comma-separated value files, calendar programs read and process calendar data files, and other programming language applications read and process files written with a particular programming language syntax.
In the next section, you’ll learn how to write programs that print the contents of a text file.