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

programs text file, binary files

Uploaded by

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

programs text file, binary files

Uploaded by

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

Define a function program1 with a file name “intro.

txt”
asking the user to write a single line of text by user input.
Define a function program4 to count the total number of upper
case, lower case, and digits used in the text file “merge.txt”.
Define a function as program5 to count a total number of lines and
count the total number of lines starting with ‘A’, ‘B’, and ‘C’.
(Consider the merge.txt file)
Define a function program6 to find the total occurrences of a
specific word from a text file
Write a program to know the cursor position and print the
text according to below-given specifications:
1.Print the initial position
2.Move the cursor to 4th position
3.Display next 5 characters
4.Move the cursor to the next 10 characters
5.Print the current cursor position
6.Print next 10 characters from the current cursor position
Write a program in python to replace all word “the”
by another word “them” in a file “poem.txt”
Find the output of the following:
Find the output of the following:
Write a program in python to replace a character
by another character in a file “story.txt”. (Accept
the characters from the user)
Write a python code to read a file “data.txt”
and display only those lines whose length is
more than 4 characters.
Write a program in python to remove all
duplicate lines from the file “story.txt”
Write a program in python to display only
unique words from the file “story.txt”
Write a program in python to count those
words whose length is more than 7 characters
in a file “story.txt”
Write a program to copy the alternate lines
from “data.txt” to “story.txt”
Write a program to read the entire content
from file “data.txt” and copy only those words
to “story.txt” which starts with vowel
A binary file “Book.dat” has structure [BookNo,
BookName,Author, Price]

1. Write a user defined function createFile() to


input data for a record and add to Book.dat

2. 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”
A binary file “student.dat” has structure
[admission_Number, Name, Percentage]

Write a function countrec() in Python that would


read contents of the file “student.dat” and display
the details of those students whose percentage is
above 75.
Also display number of students scoring above
75%.
Write a function in python to search and display
details, whose destination is “Cochin” from file
“Bus.dat”.Assuming the binary file is containing
the following elements in the list:

1. Bus number
2. Bus starting point
3. Bus destination

You might also like