You are on page 1of 1

Work Sheet

Text File

Q1. Write a function in python to count the number lines in a text file ‘Country.txt’ which is starting with an alphabet ‘W’ or
‘H’.

Q2. Write a user defined function countwords() to display the total number of words present in the file from a text file
Quotes.Txt”.

Q3. Write a function COUNT_AND( ) in Python to read the text file “STORY.TXT” and count the number of times “AND” occurs
in the file. (include AND/and/And in the counting)

Q4. Write a function DISPLAYWORDS( ) in python to display the count of words starting with “t” or “T” in a text file
‘STORY.TXT’.

Q5. Write a function that counts and display the number of 5 letter words in a text file “Sample.txt

Q6. Write a function in python to read lines from file “POEM.txt” and display all those words, which has two characters in it.

Q7. Write a function COUNT() in Python to read contents from file “REPEATED.TXT”, to count and display the occurrence of
the word “Catholic” or “mother”.

Q8. Write a function SHOW_TODO() in python to read contents from a text file ABC.TXT and display those lines which have
occurrence of the word ‘‘TO’’ or ‘‘DO’’.

Q9. Write a function in Python that counts the number of “Me” or “My” words present in a text file “STORY.TXT”.

Q10. Write a Python program to find the number of lines in a text file ‘abc.txt’.

Q11. Write a function VowelCount() in Python, which should read each character of a text file MY_TEXT_FILE.TXT, should
count and display the occurrence of alphabets vowels.

Q12. Write a function filter(oldfile, newfile) that copies all the lines of a text file “source.txt” onto “target.txt” except those
lines which starts with “@” sign.

Q 13. Write a method in python to write multiple line of text contents into a text file mylife.txt.

Q14. A text file “PYTHON.TXT” contains alphanumeric text. Write a program that reads this text file and writes to another file
“PYTHON1.TXT” entire file except the numbers or digits in the file.

Q15. Write a program to know the cursor position and print the text according to below-given specifications:

Print the initial position

Move the cursor to 4th position

Display next 5 characters

Move the cursor to the next 10 characters

Print the current cursor position

Print next 10 characters from the current cursor position

You might also like