File Handling Questions To Practice For Term1 Practical
File Handling Questions To Practice For Term1 Practical
FILE HANDLING
1. Write a program to read a text file a1.txt, line by line and display each word separated by a #.
2. Write a program to read a text file word.txt and display the number of spaces/words/digits vowels/
consonants/ uppercase/ lowercase characters in the file.
3. Write a program to read a file FILE1.TXT , Remove all the lines that contain the character `a' and write those to
another file FILE2.TXT.
12 Write a program to read a text file EMAIL.TXT and display the number of gmail ids .Also the program should
display the most occurring word in the file.
i. Take the input from the user for 3 companies and write in COMPANY.DAT
II. Display those members where TURNOVER of the company is more than 5 Crores.
The above should be able to perform the functionality on a dictionary STUDENTDATA(having roll number and
stream). Also end of file and file not found error should be handled.
15. Write a program to create a csv file sports.csv (through the list) to take inputs sportscode, nameofthesport,
noofcompetitionsheld and prizeswon. Ask for the choice from the user and keep adding till user enters ‘Y’ as
choice.
16. Considering the same file above in question 15, display all the records from the file where nameofthesport is
entered by the user.
17. Jacqline of class 12 is writing a program to create a CSV file “user.csv” which will contain user name and
password for some entries. While taking input from the user, password should be checked for the following
conditions:
1. at least 8 characters long
2 should have one upper case character
3. should have at least one digit.
4. should have one special character.
18. Professor Islam has told students to create a csv file having research id and data collected (numeric) from an
experiment. The file should have at least 5 records. Write a program to read a file RESEARCH.CSV created and
display only those records where data collected is more than 52.