Answers File Handling
Answers File Handling
f=open('Practice.txt','r')
w=f.readlines()
a=[]
g=0
for s in w:
y=s.split()
a=a+y
for z in a:
t=len(z)
for v in range(0,t):
j=str(z[v])
c=j.islower()
if c==True:
g=g+1
print(z[v])
print('The number of lowercase alphabets is',g)
2 f=open('Practice.txt','r')
w=f.readlines()
z=[]
i=0
s=0
bs=0
a=0
for x in w:
v=x.splitlines()
for d in v:
k=str(d)
o=list(k)
z=z+o
for u in z:
if u==' ':
bs=+1
elif u in '1234567890':
i=+1
elif u in 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ':
a=+1
else:
s=+1
print('NO of spaces',bs)
print('no of integers',i)
print('no of special characters',s)
3 f=open('Practice.txt','r')
w=f.readlines()
z=[]
y=0
for x in w:
v=x.splitlines()
for d in v:
k=str(d)
o=list(k)
z=z+o
for u in z:
if u in 'aeiouAEIOU':
y=y+1
for p in w:
d=p.split()
for g in d:
if g[0] in 'aeiouAEIOU':
print(g)
print('NO of vowels',y)
4 f=open('Practice.txt','r')
w=f.readlines()
v=[]
for x in w:
c=x.split()
v=v+c
d=len(v)
print('no of elements is',d)
6
f=open('Practice.txt','r')
w=f.readlines()
v=[]
for x in w:
c=x.split()
v=v+c
s=len(v)
u=0
for t in v:
f=str(t)
y=len(f)
u=u+y
7f=open('Practice.txt','r')
w=f.readlines()
v=[]
for x in w:
c=x.split()
v=v+c
print('this are',v.count('this'))
print('theese are',v.count('these'))
8def readf():
filename=input('Enter text file name with extension')
f=open(filename,'r')
w=f.readlines()
v=[]
for x in w:
c=x.splitlines()
v=v+c
for s in v:
if s[0]in'PA':
print(s)
f.close()
readf()