Text File Handling
Text File Handling
Text File Handling
Q3. Write a program in python to read first line from the file("data.txt")
Q5. Write a program in python to display first line from the file("data.txt")
using readlines().
Q6. Write a program in python to display first character of all the lines from the
file("data.txt").
Q7. Write a program in python to display all the lines from the file("data.txt")
with first character in uppercase.
NOTE: The above program will also count EOF character so displayed length of
file is different from actual length of file
Q9. Write a program in python to find the number of characters in first line of
file ("data.txt") using readline()
Q10. Write a program in python to find the number of characters in first line of
file ("data.txt") using readlines().
Q11. Write a program in python to display last two characters of all the lines
from the file("data.txt").
Q12. Write a program to read all the characters from the file("data.txt") and
display in uppercase.
Q13. Write a program to count all the upper case characters from the file
("data.txt").
Q14. Write a program to count number of spaces from the file ("data.txt").
Q17. Write a program to read data from "data.txt" and write in another file
"dest.txt"
Q18. Write a program to read all data from "data.txt" and write entire data in
another file "dest.txt" except the spaces.
Q19. Write a program to read all data from "data.txt" and write in another file
"dest.txt" except the vowels.
Q20. Write a program to read all data from "data.txt" and write alternate line
(write first line, skip second line and so on)to another file "dest.txt".
Q21. Write a program to read data from file "data.txt" and count the frequency
of word input from user.
Q22. Write a program to read entire data from the file "data.txt" and write only
those lines to file "dest.txt" which starts from word "The".
Q23. Write a program to read entire data from file "data.txt" using readline()
method.
NOTE: We can read entire data of a file using read(), readline() and readlines()
Q24. Write a program to read the content from file "data.txt" and write to file
"dest.txt" after changing the case(convert lower case to upper case and vice-
versa)
Q25. Write a program to create a list of 5 numbers (input from user) and write
that list in a file "data.txt".
https://cs-ip-practicetestseries.blogspot.com/p/class-xii-data-file-handling-solved.html