1.
Write a user defined func on in python names showLines() which reads contents of a text file
named [Link] and displays every sentence in a separate line. Assume that a sentence ends
with a full stop(.), a ques on marks(?), or an exclama on marks(!).
2. Write a func on c_words() in python that separatly counts and displays the number of
uppercase and lowercase alphabets in a text file, [Link].
3. Write a func on in Python that displays the book names having 'Y' or 'y' in their name from a
text file [Link]
Example :
if the file "[Link]" contains the names of following books :
One Hundred Years of Solitude
The Diary of a Young Girl
On the Road
A er execu on, the output will be :
One Hundred Years of Solitude
The Diary of a Young Girl
4. Write a func on RevString() to read a tex ile "[Link]" and prints the words star ng with 'O' in
reverse .The rest of the content is displayed normally.
Example :
If content in the text file is :
UBUNTU IS AN OPEN SOURCE OPERATING SYSTEM
Output will be :
UBUNTU IS AN NEPO SOURCE GNITAREPO SYSTEM
5. Write a func on COUNT() in Python to read from a text file 'Gra [Link]' and display the count
of the le er 'e' in each line.
Example: If the file content is as follows:
Gra tude is a humble heart's radiant glow,
A meless gi that nurtures and bestows.
It's the apprecia on for the love we're shown,
In moments big and small, it's truly known.
The COUNT() func on should display the output as:
Line 1 : 3
Line 2 : 4
Line 3 : 6
Line 4 : 1
6. Write a func on Start_with_I() in Python, which should read a text file 'Gra [Link]' and then
display lines star ng with 'I'.
Example: If the file content is as follows:
Gra tude is a humble heart's radiant glow,
A meless gi that nurtures and bestows.
It's the apprecia on for the love we're shown,
In moments big and small, it's truly known.
Then the output should be
It's the apprecia on for the love we're shown,
In moments big and small, it's truly known.
7. Write a func on in Python to read a text file, [Link] and displays those lines which begin with
the word ‘You’.
8. Write a func on, vowelCount() in Python that counts and displays the number of vowels in the
text file named [Link].
9. Write a method COUNTLINES() in Python to read lines from text file‘[Link]’ and display
the count lines which are not star ng with any vowel.
Example:
If the file content is as follows:
An apple a day keeps the doctor away.
We all pray for everyone’s safety.
A marked difference will come in our country.
The COUNTLINES() func on should display the output as:
The number of lines not star ng with any vowel – 1
10. Write a func on ETCount() in Python, which should read each character of a text file
“[Link]” and then count and display the count of occurrence of alphabets E and T
individually (including small cases 'e' and 't' too).
Example:
If the file content is as follows:
Today is a pleasant day.
It might rain today.
It is men oned on weather sites
The ETCount() func on should display the output as:
E or e: 6
T or t : 9
11. WAP to read the data from a file “[Link]” and copy all vowels In a file “[Link]”, all
consonants in a file “[Link]” and rest of characters in a file “[Link]”.
12. WAP to read the data from “[Link]” and display all lines having at least 4 vowels in it.
13. WAP to read the data from a file “[Link]” and display all words having at least 2 digits in it.