The text book has a chapter on File Handling ( open() , read() , write() ). Since you have a PDF, you don't need to type the entire data.txt content manually. Copy the text from the PDF, paste it into a Notepad file, save it, and run the program. This saves precious practice time.
The textbook published by is structured exactly according to the latest CBSE Class 12 Computer Science curriculum . class 12 preeti arora python pdf
This is a common problem. Students download a PDF dated "2018" and study functions from Python 2.7. The text book has a chapter on File