[go: up one dir, main page]

0% found this document useful (0 votes)
24 views3 pages

12 Practice Qns File Handling

The document provides updated practice questions for file handling in both text and binary formats. It includes exercises focused on character, word, line, mixed-type processing for text files, and record, list, dictionary, and object-based handling for binary files. Each section contains specific tasks aimed at enhancing skills in reading, writing, and manipulating file data.

Uploaded by

c5726937
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views3 pages

12 Practice Qns File Handling

The document provides updated practice questions for file handling in both text and binary formats. It includes exercises focused on character, word, line, mixed-type processing for text files, and record, list, dictionary, and object-based handling for binary files. Each section contains specific tasks aimed at enhancing skills in reading, writing, and manipulating file data.

Uploaded by

c5726937
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

12 Practice Qns File Handling

(Text, Binary)
TEXT FILE HANDLING – Updated Practice Questions ---🔹 1.

Character-Based (Revised)📘 Focus: Read character by

character using read()1. Count the total number of non-

space characters in the file.2. Count how many digits,

alphabets, spaces, and special characters are present.3.

Ask user for a character and count its frequency.4. Extract

and display only punctuation marks used in the file.5.

Replace all vowels with # and store the result in

vowelmasked.txt.---🔹 2. Word-Based (Revised)📘 Focus: Use

read().split() to process words1. Count how many words

have more than 7 characters.2. Display all words that start

and end with the same letter.3. Create a new file with all

uppercase words from the original file.4. Count how many

words contain the letter 'z'.5. Find and display the second

most frequent word.---🔹 3. Line-Based (Revised)📘 Focus:

Use readlines() or iterate line by line1. Count how many

lines start with a capital letter.2. Display all lines that

contain a number (e.g., "Room 101").3. Count how many

lines end with a question mark.4. Display the longest line

(by character length).5. Copy only lines that do not


contain the word "error" to a new file.---🔹 4. Mixed-Type

(Revised)📘 Combination of character, word, and line

processing1. Print a report showing character count, word

count, and line count in the file.2. Count the number of

blank lines and lines with only spaces.3. Create a

frequency table of first letters of each word (e.g., A:5,

B:2...).4. Display all words that are repeated in multiple

lines.5. Create a summary that shows:Total linesLines

ending with '.'Words longer than 10 charactersMost used

special character---✅ BINARY FILE HANDLING – Updated

Practice Questions ---🔹 1. Record-Based (Revised)📘 Focus:

Handle multiple records using pickle.dump() and

pickle.load()1. Add a new employee record to a binary file

emp.dat.2. Display all records where employee salary >

50000.3. Count how many employees are from the

department 'IT'.4. Display records sorted by employee

name (alphabetically).5. Delete a record where employee

ID matches a user-given value.---🔹 2. List-Based (Revised)📘

Focus: Store and manipulate list objects1. Store a list of 10

temperatures and save to temp.dat.2. Read the list,

remove all duplicate values, and overwrite the file.3. Read

and display only even numbers from the stored list.4. Add
a new number at a user-given index and save again.5.

Display the list in reverse order without modifying the

original file.---🔹 3. Dictionary-Based (Revised)📘 Focus: Save

and update dictionary data1. Create and store a dictionary

{productID: productName} in prod.dat.2. Read the

dictionary and display all product names in uppercase.3.

Count how many products start with 'A' or 'B'.4. Update

the product name for a given product ID.5. Delete all keys

where product name length<4 and save again.---🔹 4.

Object-Based (Revised)📘 Focus: Create, store, search, and

update class objects1. Define a class Book (id, title, price)

and store 3 book objects.2. Display all book objects where

price > 500.3. Search and display a book with a user-given

title.4. Update the price of a book based on its ID.5. Delete

a book object whose title matches user input.---

You might also like