List of file handling exercises
m
1. Write a python program to create a file and write contents, save and close the file.
co
2. Write a python program to read file contents and display on console.
a.
3. Write a python program to read numbers from a file and write even, odd and prime
numbers to separate file.
ity
4. Write a python program to append content to a file.
5. Write a python program to compare two files.
ad
ne
6. Write a python program to copy contents from one file to another file.
zo
7. Write a python program to merge two file to third file.
y
8. Write a python program to count characters, words and lines in a text file.
ud
9. Write a python program to remove a word from text file.
t
10. Write a python program to remove specific line from a text file.
.s
w
11. Write a python program to remove empty lines from a text file.
w
12. Write a python program to find occurrence of a word in a text file.
w
13. Write a python program to count occurrences of a word in a text file.
14. Write a python program to count occurrences of all words in a text file.
15. Write a python program to find and replace a word in a text file.
16. Write a python program to replace specific line in a text file.
17. Write a python program to print source code of same program.
18. Write a python program to convert uppercase to lowercase character and vice versa in a
text file.
m
19. Write a python program to find properties of a file using stat() function.
co
20. Write a python program to check if a file or directory exists.
a.
21. Write a python program to rename a file using rename() function.
ity
22. Write a python program to list all files and sub-directories recursively.
ad
ne
y zo
t ud
.s
w
w
w