0% found this document useful (0 votes)
87 views36 pages

Python File Manipulation Tasks

Uploaded by

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

Python File Manipulation Tasks

Uploaded by

mm718982
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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 “[Link]”.
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 [Link] 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:
[Link] the initial position
[Link] the cursor to 4th position
[Link] next 5 characters
[Link] the cursor to the next 10 characters
[Link] the current cursor position
[Link] 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 “[Link]”
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 “[Link]”. (Accept
the characters from the user)
Write a python code to read a file “[Link]”
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 “[Link]”
Write a program in python to display only
unique words from the file “[Link]”
Write a program in python to count those
words whose length is more than 7 characters
in a file “[Link]”
Write a program to copy the alternate lines
from “[Link]” to “[Link]”
Write a program to read the entire content
from file “[Link]” and copy only those words
to “[Link]” which starts with vowel
A binary file “[Link]” has structure [BookNo,
BookName,Author, Price]

1. Write a user defined function createFile() to


input data for a record and add to [Link]

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

Write a function countrec() in Python that would


read contents of the file “[Link]” 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
“[Link]”.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