0% found this document useful (0 votes)
9 views2 pages

Logical Text File Handling Questions

The document outlines a series of logical Python text file handling tasks, including reversing words, finding the longest word, removing duplicates, and counting paragraphs. It also includes challenges such as detecting palindromic words, replacing digits with words, and checking for anagram pairs. Each task is designed to enhance file manipulation and text processing skills in Python.

Uploaded by

optinex.1234
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

Logical Text File Handling Questions

The document outlines a series of logical Python text file handling tasks, including reversing words, finding the longest word, removing duplicates, and counting paragraphs. It also includes challenges such as detecting palindromic words, replacing digits with words, and checking for anagram pairs. Each task is designed to enhance file manipulation and text processing skills in Python.

Uploaded by

optinex.1234
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Logical Python Text File Handling Questions (No CSV/Binary)

1. Reverse Words in Each Line:

Reverse the order of words in each line of a text file while keeping the lines in the same order.

2. Longest Word with Line Number:

Find and print the longest word in the entire file and the line number it appears on.

3. Remove Duplicate Lines:

Remove duplicate lines from a text file, keeping only the first occurrence.

4. Word Frequency Without Using `.split()`:

Count word frequencies without using the `.split()` method.

5. Mirror Line Check:

Print line numbers of all consecutive line pairs where the second line is the reverse of the first.

6. Paragraph Count:

Count how many paragraphs are there, assuming a paragraph is separated by one or more blank

lines.

7. Word Ladder:

Detect sequences of words where each word differs by exactly one letter.

8. Palindromic Words:

Print all unique palindromic words found in the file.

9. Replace Digits with Words:

Replace every digit (09) in the file with its word form (e.g., 1 one).

10. Balanced Brackets Line:

Print all lines from the file that contain balanced round, square, and curly brackets.

11. Count Vowel-Heavy Words:

Count all words that have more vowels than consonants.

12. Line Length Histogram:


Print a histogram (using `*`) showing the length of each line in the file.

13. Alliteration Detector:

Print all sets of three or more consecutive words in a line that start with the same letter.

14. Most Repeated Line:

Find and print the line that appears the most times in the file and how many times.

15. Word Before and After:

Find a given word and print the word that appears before and after it in the line (if any).

16. Sentence Count:

Count how many complete sentences there are. A sentence ends with `.`, `!`, or `?`.

17. Reverse Entire File Content:

Reverse the entire content of the file (character by character), not just by line or word.

18. Check Anagram Pairs:

Find pairs of lines that are anagrams of each other.

19. Remove Extra Spaces:

Clean each line so that theres only one space between words, and no spaces at the start or end.

20. Line Palindrome:

Print lines that are full palindromes (the whole line reads the same forward and backward).

You might also like