You are on page 1of 1

URK22CS7012

EX NO:6 Usage of Files operations in Python URK22CS7012


29-01-2023

Aim:
A)Write a Python function that accepts a file and performs the following operation,
• calculate the number of upper-case letters and lower-case letters from the entire content of
the file.
• Search a word in a particular line
• Search a word in the range of lines
• Replace a word in the file
B)Read the input from the console and write it into a file until the word end of the line
reaches.
C)Write a python program to find the longest word in a file
Description:
file is a collection of data’s.it stores related data,information ,settings or commands in
secondary storage device like magnetic disk,magnetic tape,optical disk,flash memory.
TYPES:
-text file: consists of sequence of characters.
-binary file:stores data in the binary format.
VARIOUS FILE MODE:
‘r’,’a’,’w’,’r+’ FILE OPERATIONS:
- Opening of file:
- reading of file.
- writing of file
- closing of file.
SYNTAX:
1) fp=open(“a.txt”,”r”)
2) file_name.read()
3) file_name.write()
4) filename.close()

You might also like