Chapter 05 - File Handling
Chapter 05 - File Handling
Type C: Programming Practice/ Knowledge based Questions
1. Write a program that reads a text file and creates another file that is identical except that every sequence of consecutive blank spaces is replaced by a single space.
2. A file sports.dat contains information in following format: Event ~ Participant.
Write a function that would read contents from file sports.dat and create a file named Atheletic.dat copying only those records from sports.dat where the event name is "Athletics".
3. A file contains a list of telephone numbers in the following form:
Arvind 7258031
Sachin 7259197
The names contain only one word the names and telephone numbers are separated by white spaces. Write a program to read a file and display its contents in two columns.
4. Write a program to count the words 'to' and 'the' present in a text file "Poem.txt".
5.Write a program to count the number of upper-case alphabets present in a text file "Article.txt"
6. Write a program that copies one file to another. Have the program read the file names from user?
7. Write a program that appends the contents of a one file to another. Have the program take the filenames from the user.
8. Write a program that reads characters from the keyboard one by one. All lower case character s get stored inside the file LOWER, all upper case characters get stored inside the file UPPER and all other characters get stored inside file OTHERS.
9. Write a function in Python to count and display the number of lines starting with alphabet 'A' present in a text file "LINES.TXT". e.g., the file "LINES.TXT" contains the following lines:
A boy is playing there.
There is a playground.
An aeroplane is in the ksy.
Alphabets & numbers are allowed in password.
the function should display the output as 3.
Comments
Post a Comment