You are on page 1of 1

PRACTICAL-12

Ques. Write a pyhton program to find out the size of the files in bytes, number
of lines and number of words .
f=open('new.txt','r')

str=f.read()

size=len(str)

print('Size of the file in bytes :',size)

f.seek(0)

L=f.readlines ()

b=[]

for i in L:

a =i.split()

b+=a

print('Number of lines :',len(L))

print('Number of words :',len(b))

f.close()

OUTPUT -
Size of the file in bytes : 192

Number of lines : 8

Number of words : 37

➢ New.txt

perhaps the light

that made her beautiful

was not from her eyes,

nor from her smile

but from the way

that no matter the darkness

that swirled around her

She still found the courage to shine .

You might also like