Professional Documents
Culture Documents
Revisionpgms Files Interfacewithmysql
Revisionpgms Files Interfacewithmysql
#File copy except the letter 'a' using line by line #Count Vowels , consonant, special char , digits etc.,
f1=open('note.txt') f1=open('note.txt')
f2=open('B.txt','w') f2=open('B.txt','w')
d=f1.readline() d=f1.read() #d=input('Enter any String :')
while d!='': Vow=['a','e','i','o','u','A','E','I','O','U']
if 'a' not in d: V=C=U=L=O=0
f2.write(d) for i in d:
d=f1.readline() if i.isalpha():
#print('*',end='') if i.isupper():
f2.close() U+=1
f1.close() else:
print('File copied') L+=1
if i in Vow:
#convert lowercase to uppercase and vice-versa V+=1
f1=open('note.txt') else:
f2=open('B.txt','w') C+=1
d=f1.read() else:
#d=input('Any String :') O+=1
for i in d: print("Number of Vowels : ",V)
if i.isupper(): print("Number of Consonants : ",C)
x=i.lower() print("Number of Uppercases : ",U)
else: print("Number of Lowercases : ",L)
x=i.upper() print("Number of Others : ",O)
f2.write(x)
#print(x,end='') f2.close()
f2.close() f1.close()
f1.close() print('File copied')
print('File copied')
1
Page
#Display the words which are less than 4 characters #Display the words which are end with 'n'
f1=open('note.txt') f1=open('note.txt')
def disp(): def disp():
d=f1.readline() d=f1.readlines()
while d!='': cnt=0
Words=d.split() for i in d:
for word in Words: Words=i.split()
if len(word)<4: for word in Words:
print(word,end=' ') if word[-1]=='n':
d=f1.readline() cnt+=1
disp() print(word,end=' ')
f1.close() print("\nTotal number of words end with 'n' is ",cnt)
disp()
f1.close()
3
Page
8
Page