Professional Documents
Culture Documents
2. Write a method DISP() in Python to read lines from a text file NOTES.TXT, and (2)
count those lines, which are ending with ‘.’ or ‘,’.
3. Write a method DISPP() in Phyton to read lines from a text file DIARY.TXT, and (2)
display those lines, which are starting with an alphabet ‘P’.
f=open("data.txt",'w')
f.write("Hello")
f.write("Welcome to my Blog")
f.close()
f=open("data.txt",'r')
d=f.read()
print(len(d))
a) 5 b) 18 c) 23 d) 25
5. To read 30 characters from file object File at once we may use(assume file object is (1)
proper)
a) File.read(30) b) File.readlines(30)
c) File.read(char=30) d) File.readline(char=30)
6. Write a user defined function DISP_WORDS() to display the total number of words (2)
present in text file ‘abc.txt’.
7. Write a method/function disp_total() in python to read contents from a text file (2)
SEARCH.TXT, to count and display the occurrence of the word “He” and “HIS”
separately.
8. Write a method/function disp_total() in python to read contents from a text file (2)
SEARCH.TXT, to count and display the occurrence of the word “He” or “HIS”.
9. Write a method/function DISP_LINES() in Python to read lines from a text file (2)
TEMP.TXT, and display those lines, which are smaller than 50 characters.
10. Write a function COUNT_ALPHA() to count the no. of alphabets, vowels, (3)
consonants, uppercase characters and lowercase characters present in text file
“abc.txt”.
11. Write a function Show_words() in python to read the content of a text file ‘xyz.TXT’ (2)
and display only such lines of the file which have exactly 6 words in them.
13. Write a program to delete word ‘The’ from the file ‘abc.txt’. (2)
14. Write a method COUNTLINES() in Python to read lines from text file (3)
‘TESTFILE.TXT’ and display the lines which are not starting with any consonant.
15. Write a function ETCount() in Python, which should read each character of a text file (2)
“TESTFILE.TXT” and then count and display the count of occurrence of alphabets E
and T individually (including small cases e and t too).
16. Write a function Show_words() in python to read the content of a text file ‘xyz.TXT’ (2)
and display only such words of the file which have exactly 6 characters in them.
17. Write a function Show_words() in python to read the content of a text file ‘xyz.TXT’ (2)
and display only such words of the file which start with vowel.
18. Write a function Show_words() in python to read the content of a text file ‘xyz.TXT’ (2)
and display only such lines of the file which does not have ‘.’.
19. Write a function Show_words() in python to read the content of a text file ‘xyz.TXT’ (2)
and display only such words of the file which does not have digits in them.
20. Write a function Show_words() in python to read the content of a text file ‘xyz.TXT’ (2)
and display only such words of the file which does not have capital letters in them.