0% found this document useful (0 votes)
5 views6 pages

Python Assignment: #Source Code

The document contains a Python assignment with a series of functions that manipulate and analyze text from a file named 'Failaka.txt'. It includes functionalities to append text, count characters, and categorize them into upper/lower case, digits, and special characters. A menu-driven interface allows users to interact with these functions and view results based on their selections.

Uploaded by

vratteshanand308
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views6 pages

Python Assignment: #Source Code

The document contains a Python assignment with a series of functions that manipulate and analyze text from a file named 'Failaka.txt'. It includes functionalities to append text, count characters, and categorize them into upper/lower case, digits, and special characters. A menu-driven interface allows users to interact with these functions and view results based on their selections.

Uploaded by

vratteshanand308
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

35

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

elif k.lower()not in 'aeiou':


c2+=1

elif k.lower()not in 'aeiou':


c3+=1
else:
print('not recognized')
print(c,c1,c2,c3)
file1.close()

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===========================================================
=================================")

print("1.DISPLAY THE appended text file with newtest txt")


print("2.DISPLAY THE NO OF CHARACTERS ")
print("3.DISPLAY THE NUMBER OF UPPER,LOWER,ISDIGIT,ISSPECIAL
CHARACTERS")
print("4.DISPLAY THE NO OF VOWELS IN LOWER AND UPPER")
print("5.DISPLAY THE NO OF ALPHABETIC CHARACTERS")
print("0.EXIT FROM 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

print("breaking from menu")


break

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

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 option3
not recognized
not recognized
not recognized
not recognized
not recognized
0 39 2 0 4
==========================================================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 option4
not recognized
not recognized
not recognized
not recognized
not recognized
not recognized
not recognized
not recognized
not recognized
not recognized
not recognized
3 51 0 0
==========================================================menu==
================================================================
==========================
1.DISPLAY THE appended text file with newtest txt
40

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 option5
not recognized
not recognized
not recognized
not recognized
not recognized
not recognized
not recognized
not recognized
not recognized
not recognized
not recognized
54
==========================================================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 option0
breaking from menu
'''

You might also like