0% found this document useful (0 votes)
16 views

File Handling Based Questions

The document contains a series of Python programming tasks focused on file handling with text files. Each task requires the creation of a specific function to perform operations such as counting words, filtering lines, and reading or writing to files. The tasks are designed to enhance skills in manipulating text files using Python.

Uploaded by

cbalajimohan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

File Handling Based Questions

The document contains a series of Python programming tasks focused on file handling with text files. Each task requires the creation of a specific function to perform operations such as counting words, filtering lines, and reading or writing to files. The tasks are designed to enhance skills in manipulating text files using Python.

Uploaded by

cbalajimohan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

FILE HANDLING

TEXT FILE BASED QUESTIONS

1. Write a python function that displays all the words starting

from the letter c in the text file "chars.txt" .

2. Write a python function countmy() in python to read the text

file "Data.txt" and count the number of times "my" or "My" occurs

in the file .

3. Write a function filter() that copies all the lines of a text file

"source.txt" into "target.txt" except those lines starts with "@"

sign .

4. Write a user defined function in python that displays the

number of lines starting with letter H in the file "para.txt".

5.Write a function that counts no of words beginning with a


capital letter from the text file RatanJi.txt
6. Write a function that displays the line number along with no of
words in it from the file Quotes.txt

7.Write a Python function that can read a text file and print only
numbers stored in the file on the screen (consider the text file
name as "info.txt").

8.Write a Python script to open an existing file notes.txt and


append the text "Python is fun!" to it.

9.Write a Python function to read the content from a text file


named diary.txt line by line and display each line on the screen.

10.Create a Python function that writes multiple lines of text into


a text file called mylife.txt.

You might also like