Exercise of File Handling
Exercise of File Handling
1. Write a function in python to read the content from a text file "poem.txt" line
by line and display the same on screen.
2. Write a function in python to count the number of lines from a text file
"story.txt" which is not starting with an alphabet "T".
3. Write a function in Python to count and display the total number of words in a
text file.
4. Write a function in Python to read lines from a text file "notes.txt". Your
function should find and display the occurrence of the word "the".
Example :
If the file matter.txt has the following content stored in it :
“THE WORLD IS ROUND”
The function hash_display() should display the following content :
T#H#E# #W#O#R#L#D# #I#S# #R#O#U#N#D#
10. Aditi has used a text editing software to type some text. After saving the
article as WORDS.TXT, she realised that she has wrongly typed alphabet J in
place of alphabet I everywhere in the article.
Write a function definition for JTOI() in Python that would display the corrected
version of entire content of the file WORDS.TXT with all the alphabets "J" to be
displayed as an alphabet "I" on screen.
Note: Assuming that WORD.TXT does not contain any J alphabet otherwise.
Example:
If Aditi has stored the following content in the file WORDS.TXT:
WELL, THJS JS A WORD BY JTSELF. YOU COULD STRETCH THJS TO BE A SENTENCE
The function JTOI() should display the following content:
WELL, THIS IS A WORD BY ITSELF. YOU COULD STRETCH THIS TO BE A
SENTENCE
a) Write a python function that adds one more record at the end of file.
b) Write a python function that displays all employee records whose salary
is more than 30000.
a) Write a python function that display all records where player name starts
from 'A'
b) Write a python function that accept country as an argument and count and
display the number of players of that country.
c) Write a python function that adds one record at the end of file.
a) Write a function in Python that would read contents from the file game.dat
and creates a file named basket.dat copying only those records from
game.dat where the game name is "Basket Ball"