File Handling Assignment
File Handling Assignment
createfile(1,”Anya”)
createfile(2,”Akshita”)
createfile(3,”Krish”)
readfile() (5)
1) Name the module that should be import in line 1
2) In which mode file should be opened to add new data in file stu.dat
3)Fill in the blank in line 3 for closing the file
4)Fill in the blank in line 4 for reading content of binary file
5)Write the output after execution of line 5
3) Write a pyton function countThisThat() to count all “this” and “that” (small cases only) from text
file story.txt and print number of “this” and “that” separately 3
4) Write a python function EndingWithr() to count number of lines from a text file myfile.txt which
are ending with ‘r’ (small letter only) 3
5) Write a python function CountLength4() to read the content of file poem.txt and count and return
those words which are of 4 characters or more 3
6) Write a python function countchar() to read the entire content of file drama.txt and count number
of visible characters in file ( excluding spaces and EOL character) 3
7) There is a file empdata.dat on disk with structure empid,empname and having some data
a) Write a python function adddata()to add two more records in file empdata.dat after taking input
from user and without deleting the previous records
b)Write a python function readCSV() to read the content of file emp.csv and display the data of
those employees whose names start with “S” (Capital only) 4