Text Files
1 Write a user defined function to count the no: of words present in the text file
“[Link]”.
2 Write a a user defined function to count the words “to” and “the” present in the
text file “[Link]”.
3 Write a a user defined function to count the words starting with ‘A’ or ‘a’ in the
text file “[Link]”.
Write a user defined function to count no: of lines starting with ‘S’ or ‘s’ in the text
file “[Link]”.
4 Write a function in Python that counts the number of “Me” or “My” words present
in a text file “[Link]”.
If the “[Link]” contents are as follows:
My first book was Me and My Family.
It gave me chance to be Known to the world.
The output of the function should be:
Count of Me/My in file: 4
5 Write a program to create a text file “[Link]” with rollno and name of n students.
Write functions to display the following
• Read and display n student details from a given text file “[Link]”
• Display students details whose names are starting with ‘P’
• Read and display the last student from a text file “[Link]”
6 Write a function remove_lowercase() that accepts 2 filenames and copies all lines
that do not start with a lower case letter from the first file to the second file.
7 Write a user defined function in python that displays the number of lines starting
with ‘H’ in the file ‘[Link]’.[Also display the line starting with ‘H’]
8 Write a program that copies a text file “[Link]” onto “[Link]” barring the
lines starting with a “@” sign.
9 Write a function displayWords( ) in Python to read a file “[Link]” and display
those words which are having more than 6 characters.
10 Write a python program to reverse the content of a file ‘[Link]’ and store it in
another file.
11 Write a program to display first line from 10th character onwards of a given file
‘[Link]’.
12 Write a a user defined function to count the frequency of words in a file