[Type B] File Handling – Chapter 5 Sumita Arora
Table of Contents
2. If the file ‘poemBTH.txt
‘ contains the following poem (by Paramhansa Yogananda), then what outputs will be produced by both the code fragments given in Q1.
God made the Earth; Man made confusing countries And their fancy-frozen boundaries. But with unfound boundless Love I behold the borderland of my India Expanding into the world. Hail, mother of religions, lotus, scenic beauty, and sages!
Answer: Code (a):
God made the Earth; Man made confusing countries And their fancy-frozen boundaries. But with unfound boundless Love I behold the borderland of my India Expanding into the world. Hail, mother of religions, lotus, scenic beauty, and sages!
Code (b):
God made the Earth; Man made confusing co
Explanation:
As explained in Q1, code (a) reads the entire file, resulting in the complete poem as output. Code (b) reads only the first 100 characters, including the first line and part of the second line.
Good work posting these questions in detail!