0% found this document useful (0 votes)
2 views5 pages

Python Assignment: #Source Code

The document contains a Python script that provides a menu-driven interface for analyzing a text file named 'Failaka.txt'. It includes functions to count lines, vowels, consonants, alphanumeric characters, and special characters, as well as to create a new file with uppercase text. The script allows users to execute these functions through a simple menu until they choose to exit.

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 DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views5 pages

Python Assignment: #Source Code

The document contains a Python script that provides a menu-driven interface for analyzing a text file named 'Failaka.txt'. It includes functions to count lines, vowels, consonants, alphanumeric characters, and special characters, as well as to create a new file with uppercase text. The script allows users to execute these functions through a simple menu until they choose to exit.

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 DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

PYTHON ASSIGNMENT

#VRATTESH ANAND
#CLASS-12 SECTION-B
#ROLL NO:35
#Q8:
#SOURCE CODE:

def function_FIRST():

file1=open("Failaka.txt","r")
ST=file1.readlines()
print(len(ST))

file1.close()

def function_SECOND():
file2=open("Failaka.txt","r")
st1=file2.readlines()
c=0
for k in st1:
if k[0] in 'AEIOUaeiou':
c+=1
print(c)
file2.close()

def function_THIRD():
file3=open("Failaka.txt","r")
st1=file3.readlines()

c1=0
for k in st1:
if k[-1] not in "AEIOUaeiou":
c1+=1

print(c1)
file3.close()

def function_FOURTH():
file4=open("Failaka.txt","r")
st1=file4.read()
c2=0
c3=0
for k in st1:
if k.isalnum()==True:
c2+=1

elif k.isspace()==False and k.isdigit()==False and


k.islower()==False and k.isupper()==False and
k.isalpha()==False:
c3+=1

print(c2,c3,end='')

file4.close()

def function_FIFTH():
file=open("FAILAKAUP.TXT","a")
file1=open("Failaka.txt","r")
st1=file1.readlines()
l=[]
for k in st1:
l+=k.upper()
st=file.writelines(l)
file.close()
file1.close()

while True:

print("=======================================================
===menu=======================================================
=====================================")

print("1.DISPLAY THE NO OF LINES ")


print("2.DISPLAY THE NO OF LINES WITH VOWEL ")
print("3.DISPLAY THE NUMBER OF LINES WITH CONSANSTS")
print("4.DISPLAY THE NO OF LINES WITH SPECIAL CHARACTERS
AND ALPHANUMERIC CHARACTERS")
print("5.DISPLAY THE NEW TEXT FILE WITH NEW WORDS IN UPPER
CASE")
print("0.EXIT FROM MENU")

ch=int(input("enter A option"))

if ch==1:
function_FIRST()
elif ch==2:
function_SECOND()
elif ch==3:
function_THIRD()
elif ch==4:
function_FOURTH()
elif ch==5:
function_FIFTH()
elif ch==0:
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 8.py =========
==========================================================menu
==============================================================
==============================
1.DISPLAY THE NO OF LINES
2.DISPLAY THE NO OF LINES WITH VOWEL
3.DISPLAY THE NUMBER OF LINES WITH CONSANSTS
4.DISPLAY THE NO OF LINES WITH SPECIAL CHARACTERS AND
ALPHANUMERIC CHARACTERS
5.DISPLAY THE NEW TEXT FILE WITH NEW WORDS IN UPPER CASE
0.EXIT FROM MENU
enter A option1
7
==========================================================menu
==============================================================
==============================
1.DISPLAY THE NO OF LINES
2.DISPLAY THE NO OF LINES WITH VOWEL
3.DISPLAY THE NUMBER OF LINES WITH CONSANSTS
4.DISPLAY THE NO OF LINES WITH SPECIAL CHARACTERS AND
ALPHANUMERIC CHARACTERS
5.DISPLAY THE NEW TEXT FILE WITH NEW WORDS IN UPPER CASE
0.EXIT FROM MENU
enter A option2
1
==========================================================menu
==============================================================
==============================
1.DISPLAY THE NO OF LINES
2.DISPLAY THE NO OF LINES WITH VOWEL
3.DISPLAY THE NUMBER OF LINES WITH CONSANSTS
4.DISPLAY THE NO OF LINES WITH SPECIAL CHARACTERS AND
ALPHANUMERIC CHARACTERS
5.DISPLAY THE NEW TEXT FILE WITH NEW WORDS IN UPPER CASE
0.EXIT FROM MENU
enter A option3
7
==========================================================menu
==============================================================
==============================
1.DISPLAY THE NO OF LINES
2.DISPLAY THE NO OF LINES WITH VOWEL
3.DISPLAY THE NUMBER OF LINES WITH CONSANSTS
4.DISPLAY THE NO OF LINES WITH SPECIAL CHARACTERS AND
ALPHANUMERIC CHARACTERS
5.DISPLAY THE NEW TEXT FILE WITH NEW WORDS IN UPPER CASE
0.EXIT FROM MENU
enter A option
==========================================================menu
==============================================================
==============================
1.DISPLAY THE NO OF LINES
2.DISPLAY THE NO OF LINES WITH VOWEL
3.DISPLAY THE NUMBER OF LINES WITH CONSANSTS
4.DISPLAY THE NO OF LINES WITH SPECIAL CHARACTERS AND
ALPHANUMERIC CHARACTERS
5.DISPLAY THE NEW TEXT FILE WITH NEW WORDS IN UPPER CASE
0.EXIT FROM MENU
enter A option4
314
12==========================================================me
nu============================================================
================================
1.DISPLAY THE NO OF LINES
2.DISPLAY THE NO OF LINES WITH VOWEL
3.DISPLAY THE NUMBER OF LINES WITH CONSANSTS
4.DISPLAY THE NO OF LINES WITH SPECIAL CHARACTERS AND
ALPHANUMERIC CHARACTERS
5.DISPLAY THE NEW TEXT FILE WITH NEW WORDS IN UPPER CASE
0.EXIT FROM MENU
enter A option5
==========================================================menu
==============================================================
==============================
1.DISPLAY THE NO OF LINES
2.DISPLAY THE NO OF LINES WITH VOWEL
3.DISPLAY THE NUMBER OF LINES WITH CONSANSTS
4.DISPLAY THE NO OF LINES WITH SPECIAL CHARACTERS AND
ALPHANUMERIC CHARACTERS
5.DISPLAY THE NEW TEXT FILE WITH NEW WORDS IN UPPER CASE
0.EXIT FROM MENU
enter A option0
breaking from menu
'''

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy