A text file is a sequence of characters stored on a permanent medium like a hard drive, flash memory, or CD-ROM. To read a file, you can use open to create a file object: Mode ‘r’ means that file is open for reading. The file object provides several…