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

File Handling Program List

file handling questions for computer science class 12 cbse

Uploaded by

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

File Handling Program List

file handling questions for computer science class 12 cbse

Uploaded by

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

File Handling Text

File
1. Write a Python Program to read a text file and count the number of lines ending with vowels.
2. Write a Python Program that reads a text file and create a new file after adding “ing” to all
words ending with ‘t’ , ‘p’ and ‘d’.
3. Write a function RevString() to read a textfile “Input.txt” and prints the words starting with
‘O’ in reverse order.The rest of the content is displayed normally. Example :
If content in the text file is :
UBUNTU IS AN OPEN SOURCE OPERATING SYSTEM
Output will be :
UBUNTU IS AN NEPO SOURCE GNITAREPO SYSTEM
(words ‘OPEN’ and ‘OPERATING’ are displayed in reverse order)

4. Write the definition of a function ChangeGender() in Python , which reads the contents of a
text file “BIOPIC.TXT” and displays the content of the file with every occurrence of the word ‘he’
replaced by ‘she’.
For example, if the content of the file “BIOPIC.TXT” is as follows:
Last time he went to Agra, there was too much crowd, which he
did not like.
So this time he decided to visit some hill station.
The function should read the file content and display the output as follows:
Last time she went to Agra, there was too much crowd, which she did not
like. So this time she decided to visit some hill station.
5. Write a function Show_words() in python to read the content of a text file 'NOTES.TXT' and
display the entire content in capital letters.
Example, if the file contains:
"This is a test file"
Then the function should display the output as: THIS IS A TEST FILE
6. Write a function Show_words() in python to read the content of a text file 'NOTES.TXT' and
display only such lines of the file which have exactly 5 words in them.
Example, if the file contains:
"This is a sample file.
The file contains many sentences.
But need only sentences which have only 5 words." Then the function should display the
output as: This is a sample file. The file contains many sentences.

CSV File
7. Write a Python program to write data in a csv file “Department.csv” , consisting of :
Depid ,Dept Name ,DeptLocation.
Print only the Deptname and DeptLocation.

Binary File
44. Given a binary file employee.dat, created using dictionary object having keys: (empcode,
name, and salary)

Write a python function that add one more record at the end of file.

Write a python function that display all employee records whose salary is more that 30000

45. Write a Python script to create a binary file “Flight.dat” containing information : FlightNum ,
NoOfSeats, StartingPoint and Destination.
• Display all flights with Destination =”Delhi”  Count all flights
with NoOfSeats more than 150.  Display the details of flight
with given FlightNo.
• Change the Destination to “Mumbai” for flightNum= “A102”
46. Consider a file, SPORT.DAT, containing records of the following structure: [SportName,
TeamName, No_Players]
Write a function, copyData(), that reads contents from the file SPORT.DAT
and copies the records with Sport name as “Basket Ball” to the file named BASKET.DAT. The
function should return the total number of records copied to the file BASKET.DAT

47. A binary file “Book.dat” has structure[BookNo, Book_Name, Author, Price].


Write a user defined function CreateFile() to input data for a record and add to Book.dat .
Write a function CountRec(Author) in Python which accepts the Author name as parameter
and count and return number of books by the given Author are stored in the binary file
“Book.dat”
48. A binary file “PATIENTS.dat” has structure [PID, NAME,DISEASE].
Write the definition of a function countrec() in Python that would read contents of the file
“PATIENTS.dat” and display the details of those patients who have the DISEASE as ‘COVID19’.
The function should also display the total number of such patients whose DISEASE is ‘COVID-
19’.
49. A binary file “PLANTS.dat” has structure [ID, NAME, PRICE].
Write the definition of a function WRITEREC() in Python, to input data for records from the
user and write them to the file PLANTS.dat.
Write the definition of a function SHOWHIGH() in Python, which reads the records of
PLANTS.dat and displays those records for which the PRICE is more than 500.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy