Monday, 20 July 2026
Lecture 30 of 73 · Unit 1
Unit 1 ⏳ Pending
Unlocks at 05:00 PM, 20 Jul 2026

Text file reading writing searching and counting PYQ part 3

What We'll Learn

A quick overview of today's lecture

Text file reading writing searching and counting PYQ part 3 PYQ PRACTICE SCOPE: Text file reading writing searching and counting. Concept ID: U1_TEXT_FILE_OPERATIONS. Use only previous-year questions whose concept_ids include U1_TEXT_FILE_OPERATIONS.
Key things we'll cover
Text file reading writing searching and counting
PYQ references used by both prompts 9 included 0 excluded
Flagged questions are excluded from both Study Notes and PPT references until corrected in Paper Analyzer.
Included ID 6158 · 2024 · 3 mark(s)
(a) Write the user defined function count_words() in Python to count the number of words in a text file "Story.txt".
File Handling → Text file reading writing searching and counting
Included ID 6159 · 2024 · 3 mark(s)
(b) Write the user defined function display() in Python to read the content of a text file "Story.txt" and display those words which are less than 4 characters.
File Handling → Text file reading writing searching and counting
Included ID 6358 · 2024 · 3 mark(s)
(a) Write a method/function COUNTWORDS() in Python to read contents from a text file DECODE.TXT, to count and return the occurrence of those words, which are having 5 or more characters.
File Handling → Text file reading writing searching and counting
Included ID 6359 · 2024 · 3 mark(s)
(b) Write a method/function COUNTLINES() in Python to read lines from a text file CONTENT.TXT, and display those lines, which have @ anywhere in the line. For example : If the content of the file is : Had an amazing time at the concert last night with @MusicLoversCrew. Excited to announce the launch of our new website! G20 @ India The method/function should display Had an amazing time at the concert last night with @MusicLoversCrew G20 @ India
File Handling → Text file reading writing searching and counting
Included ID 6646 · 2024 · 3 mark(s)
A) Write a Python function that displays all the words containing @cmail from a text file "Emails.txt".
File Handling → Text file reading writing searching and counting
Included ID 6647 · 2024 · 3 mark(s)
B) Write a Python function that finds and displays all the words longer than 5 characters from a text file "Words.txt".
File Handling → Text file reading writing searching and counting
Included ID 6172 · 2024 · 4 mark(s)
Write a program in Python to read the content of a text file Story.txt and count and display the number of lines that start with the letter 'A'.
File Handling → Text file reading writing searching and counting
Included ID 6378 · 2025 · 1 mark(s)
A text file 'song.txt' contains the following contents in it : Life goes on as it never ends What will be the output of the following code snippet ? f1=open("song.txt","r") s1=f1.read(5) s2=f1.readline(4) s3=f1.read(3) print(s1,s3,sep="#") (A) goes# on (B) Life #goes# on (C) Life # on (D) Error
File Handling → Text file reading writing searching and counting
Included ID 6203 · 2025 · 3 mark(s)
Write a user defined function in Python named COUNT() which counts and displays the number of lines which do not start with the vowels 'A' or 'E' in the file, "Paragraph.txt".
File Handling → Text file reading writing searching and counting
.txt