Python Assignment: #Source Code
Python Assignment: #Source Code
PYTHON ASSIGNMENT
#VRATTESH ANAND
#CLASS-12 SECTION-B
#ROLL NO:35
#Q6:
#SOURCE CODE:
import os
def function_11():
file=open("NEWTEXT.TXT","a")
file1=open("Failaka.txt","r")
st1=file1.readlines()
file.writelines(st1)
file.close()
file1.close()
def function_12():
file1=open("Failaka.txt","r")
st1=file1.read()
st2=st1.split()
print(len(st2),end='')
file1.close()
def function_13():
file1=open("Failaka.txt","r")
st1=file1.read()
st2=st1.split()
c=c1=c2=c3=c4=0
for k in st2:
if k.isalpha()==True:
if k.isupper()==True:
c+=1
elif k.islower()==True:
c1+=1
elif k.isdigit()==True:
c2+=1
elif k.isspace()==True:
36
c3+=1
elif k.isspace()==False and k.isdigit()==False and
k.islower()==False and k.isupper()==False and
k.isalpha()==False:
c4+=1
else:
print('not recognized')
print(c,c1,c2,c3,c4)
file1.close()
def function_14():
file1=open("Failaka.txt","r")
st1=file1.read()
st2=st1.split()
c=c1=c2=c3=0
for k in st2:
if k.isalpha()==True:
if k.upper() in 'AEIOU':
c+=1
elif k.upper()not in 'AEIOU':
c1+=1
def function_15():
file1=open("Failaka.txt","r")
st1=file1.read()
st2=st1.split()
37
c=0
for k in st2:
if k.isalpha()==True:
if k.upper()>="A" and k.upper()<="Z":
c+=1
else:
print('not recognized')
print(c)
file1.close()
while True:
print("=========================================================
=menu===========================================================
=================================")
ch=int(input("enter A option"))
if ch==1:
function_11()
elif ch==2:
function_12()
elif ch==3:
function_13()
elif ch==4:
function_14()
elif ch==5:
function_15()
elif ch==0:
38
else:
print('object not found , option not found')
#OUTPUT:
'''
Python 3.13.2 (tags/v3.13.2:4f8bb39, Feb 4 2025, 15:23:48) [MSC
v.1942 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more
information.
========= RESTART:
C:\Users\neels\Documents\PYTHON-FILES\question 6.py =========
==========================================================menu==
================================================================
==========================
1.DISPLAY THE appended text file with newtest txt
2.DISPLAY THE NO OF CHARACTERS
3.DISPLAY THE NUMBER OF UPPER,LOWER,ISDIGIT,ISSPECIAL CHARACTERS
4.DISPLAY THE NO OF VOWELS IN LOWER AND UPPER
5.DISPLAY THE NO OF ALPHABETIC CHARACTERS
0.EXIT FROM MENU
enter A option1
==========================================================menu==
================================================================
==========================
1.DISPLAY THE appended text file with newtest txt
2.DISPLAY THE NO OF CHARACTERS
3.DISPLAY THE NUMBER OF UPPER,LOWER,ISDIGIT,ISSPECIAL CHARACTERS
4.DISPLAY THE NO OF VOWELS IN LOWER AND UPPER
5.DISPLAY THE NO OF ALPHABETIC CHARACTERS
0.EXIT FROM MENU
enter A option2
65==========================================================menu
================================================================
============================
39