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

Python Functions for Text File Analysis

The document outlines a series of programming assignments focused on text file manipulation using Python. Tasks include counting word frequencies, vowels, and specific phrases, displaying words based on criteria, reversing text, and filtering content. Each assignment specifies the expected input and output, guiding the implementation of various functions for file handling.

Uploaded by

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

Python Functions for Text File Analysis

The document outlines a series of programming assignments focused on text file manipulation using Python. Tasks include counting word frequencies, vowels, and specific phrases, displaying words based on criteria, reversing text, and filtering content. Each assignment specifies the expected input and output, guiding the implementation of various functions for file handling.

Uploaded by

rakavip2003
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

ASSIGNMENT – TEXT FILES

1. Write a function countINDIA() which read a text file ‘[Link]’ and print the
frequency of the words ‘India’ in it (ignoring case of the word).
Example: If the file content is as follows:
INDIA is my country. I live in India. India has many states.
The countIndia() function should display the output as:
Frequency of India is 3.
2. Write a function countVowel() in Python, which should read each character of a
text file “[Link]” and then count and display the count of occurrence of vowels
(including small cases and upper case).

3. Write a function COUNT_AND( ) in Python to read the text file “[Link]” and
count the number of times “AND” occurs in the file. (include AND/and/And in the
counting)

4. Write a function DISPLAYWORDS( ) in python to display the count of words


starting with “t” or “T” in a text file ‘[Link]’.Write a method/function
DISPLAYWORDS() in python to read lines from a text file [Link], and
display those words, which are less than 4 characters.

5. Write a function RevText() to read a text file "[Link]" and Print only word starting
with 'I' in reverse order.
Example:
If value in text file is:
INDIA IS MY COUNTRY
Output will be: AIDNI SI MY COUNTRY.
6. Write a method COUNTLINES() in Python to read lines from text file
‘[Link]’ and display the lines which are starting with any article (a,
an, the) insensitive of the case.
Example:
If the file content is as follows:
Give what you want to get.
We all pray for everyone’s safety.
A marked difference will come in our country.
The Prime Minister is doing amazing things.
The COUNTLINES() function should display the output as:
The number of lines starting with any article are : 2
7. Suppose conten tof '[Link]' is:
Humpty Dumpty sat on a wall
Humpty Dumpty had a great fall
All the king's horses and all the king's men
Couldn't put Humpty together again
Write a python function named RECORD to calculate total number of lines in ‘
[Link]’
8. Write a function reverseFile()in Python, which should read the content of a text file
“[Link]” and display all its line in the reverse order.
Example: If the file content is as follows:
It rained yesterday.
It might rain today.
I wish it rains tomorrow too.
I love Rain.
The RainCount()function should display the output as:
.yadretsey deniar tI
.yadot niar thgim tI
.oot worromot sniar ti hsiw I
.niaR evol I

9. A text file “[Link]” contains alphanumeric text. Write a program that reads
this text file and writes to another file “[Link]” entire file except the
numbers or digits in the file.
10. Write a function COUNTLINES( ) which reads a text file [Link] and then
count and display the number of the lines which starts and ends with same letter
irrespective of its case . For example if the content of the text file [Link] is :
The person has a sent a lovely tweet
Boy standing at station is very disturbed
Even when there is no light we can see
How lovely is the situation
The expected output is :
The Number of lines starting with same letter is 2

You might also like