MENU BASED PROGRAM (2)
MENU BASED PROGRAM (2)
MENU BASED PROGRAM (2)
def countwards(s,ch):
ctr=0
l=s.split()
for i in l:
if i[0].upper()==ch.upper():
print(i)
ctr=ctr+1
def reverse(s):
l=s.split()
l=l[::-1]
for i in l:
print(i,end='')
def longest(line):
s=line.split()
z=len(s[0])
y=s[0]
for i in range(1,len(s)):
if len(s[i])>z:
z=len(s[i])
y=s[i]
print(z)
print(y)
#4.FREQUENCY OF ALL ALPHABETS IN THE LINE
d={}
n=''
for i in line:
if i.isalpha():
n=n+i
n=n.upper()
for a in n:
if a in d:
d[a]=d[a]+1
else:
d[a]=1
print('CHARACTER\tFREQUENCY')
for b in d:
print(b,'\t\t',d[b])
def replacevowel(word):
z=''
l=len(word)
for i in range(l):
if word[i] in 'AEIOUaeiou':
x=ord(word[i])
x=x+1
x=chr(x)
z=z+x
else:
z=z+word[i]
print(z)
l=line.split()
for word in l:
for i in range(len(word)):
if word[i]in 'AEIOUaeiou':
pword=word[i:]+word[:i]+'AY'
break
else:
pword=word+'AY'
print(word,'\t' '\t',pword)
def palindrome(line):
l=line.split()
for a in l:
if a==a[::-1]:
print(a,'\t\t' 'YES')
else:
print(a,'\t\t' 'NO')
def frequencytable(line):
d={}
n=''
for a in line:
if a.isdigit():
n=n+1
n=n.upper()
for k in n:
if k in d:
d[k]=d[k]+1
else:
d[k]=1
print('DIGIT\t\tFREQUENCY')
for j in d:
print(j,'\t\t',d[k])
def menu():
while True:
print('5:REPLACE A VOWEL')
print('7:PALINDROME WORDS')
print('8:FREQUENCY TABLE')
print('9:EXIT')
if op==1:
ch=input('ENTER ALPHABET:')
countwards(s,ch)
elif op==2:
s=input('ENTER SENTENCE:')
reverse(s)
elif op==3:
longest(line)
elif op==4:
frequency(line)
elif op==5:
replacevowel(word)
elif op==6:
piglatin(line)
elif op==7:
palindrome(line)
elif op==8:
frequencytable(line)
else:
break
menu()
output
MAIN MENU
5: REPLACE A VOWEL
7: PALINDROME WORDS
8: FREQUENCY TABLE
9: EXIT
ENTER ALPHABET:T
THIS
TAJ
5: REPLACE A VOWEL
7: PALINDROME WORDS
8: FREQUENCY TABLE
9: EXIT
5: REPLACE A VOWEL
7: PALINDROME WORDS
8: FREQUENCY TABLE
9: EXIT
STATEMENT
5: REPLACE A VOWEL
8: FREQUENCY TABLE
9: EXIT
CHARACTER
FREQUENCY
REES T
AMNH
1
5: REPLACE A VOWEL
7: PALINDROME WORDS
8: FREQUENCY TABLE
9:EXIT
JN
JNT
JNTF
JNTFR
JNTFRF
JNTFRFS
JNTFRFST
JNTFRFSTJ
JNTFRFSTJN
JNTFRFSTJNG
5: REPLACE A VOWEL
7: PALINDROME WORDS
8: FREQUENCY TABLE
9: EXIT
ENTER THE CHOICE:7
WORD
PALINDROME
MADAM
YES
IS
NO
TEACHING
5: REPLACE A VOWEL
8: FREQUENCY TABLE
9: EXIT
WORD
PIGLATION
THIS
ISTHAY
IS
ISAY
MY
MYAY
BOOK
OOKBAY
MENU BASED PROGRAM FOR LISTS
def greattwo(l):
n=[]
for i in l:
if len(str(i))==2:
n.append(i)
n.sort(reverse=True)
def check(s):
import statistics as x
print('HIHEST:',max(s))
print('LOWEST:',min(s))
print('MEAN:',x.mean(s))
print('MEDIAN:',x.median(s))
print('MODE:',x.mode(s))
def alpha(s):
while (len(alp))!=1:
for i in l:
if[0].upper()==let.upper():
print(i)
def shift(l):
i=0
j=len(l)-1
while i<j:
while l[i]%2==0:
i=i+1
while l[j]%2!=0:
j=j-1
if i<j:
l[i],l[j]=l[j],l[i]
print(l)
l=[]
def ascend(L):
print('ORIGINAL LIST',L)
L.sort()
L.sort(reverse=True)
def even(l):
print('ORIGININAL LIST;',l)
for i in l:
if i%2==0:
l.remove(i)
print('UPDATED LIST:',l)
def update(l):
a=len(l)
for i in range(a):
if l[i]>0:
l[i]=l[i]*2
else:
l[i]=l[i]+5
print('UPDATED LIST:',l)
def menu():
while True:
print('2:HIGHEST,LOWEST')
print('4:SHIFT NUMBERS')
print('8:EXIT')
if op==1:
l=[]
no=int(input('ENTER NO :'))
l.append(no)
greattwo(l)
elif op==2:
s=[]
no=int(input('ENTER NO :'))
s.append(no)
check(s)
elif op==3:
l=[]
s=input('ENTER SENTENCE:')
alpha(s)
elif op==4:
l=[]
n=int(input('HOW MANY NUMBERS:'))
no=int(input('ENTER NO :'))
l.append(no)
shift(l)
elif op==5:
l=[]
no=int(input('ENTER NO :'))
l.append(no)
ascend(l)
elif op==6:
l=[]
no=int(input('ENTER NO :'))
l.append(no)
even(l)
elif op==7:
l=[]
no=int(input('ENTER NO :'))
l.append(no)
update(l)
else:
break
menu()
output
1) MAIN MENU
2:HIGHEST,LOWEST
4:SHIFT NUMBERS
6:REMOVE EVEN NO
7:MULTIPLY POSITIVE NO
8:EXIT
ENTER NO :45
ENTER NO :34
ENTER NO :56
ENTER NO :23
ENTER NO :19
2) MAIN MENU
2:HIGHEST,LOWEST
4:SHIFT NUMBERS
6:REMOVE EVEN NO
7:MULTIPLY POSITIVE NO
8:EXIT
ENTER NO :48
ENTER NO :97
ENTER NO :69
ENTER NO :87
HIHEST: 97
LOWEST: 48
MEAN: 75.25
MEDIAN: 78.0
MODE: 48
3) MAIN MENU
2:HIGHEST,LOWEST
4:SHIFT NUMBERS
6:REMOVE EVEN NO
7:MULTIPLY POSITIVE NO
8:EXIT
ENTER NO :23
ENTER NO :46
ENTER NO :56
ENTER NO :79
ENTER NO :88
ENTER NO :45
4) MAIN MENU
4:SHIFT NUMBERS
6:REMOVE EVEN NO
7:MULTIPLY POSITIVE NO
8:EXIT
ENTER NO :24
ENTER NO :56
ENTER NO :79
ENTER NO :87
ENTER NO :65
ENTER NO :45
6) MAIN MENU
2:HIGHEST,LOWEST
4:SHIFT NUMBERS
6:REMOVE EVEN NO
7:MULTIPLY POSITIVE NO
8:EXIT
ENTER NO :23
ENTER NO :44
ENTER NO :64
ENTER NO :76
ENTER NO :55
ENTER NO :89
7) MAIN MENU
2:HIGHEST,LOWEST
4:SHIFT NUMBERS
6:REMOVE EVEN NO
7:MULTIPLY POSITIVE NO
8:EXIT
ENTER NO :67
ENTER NO :-32
ENTER NO :-43
ENTER NO :-41
ENTER NO :23
ENTER NO :67
def countcapt():
d={}
for i in range(n):
d[cntry.upper()]=capt.upper()
ctr=1
for count in d:
print(ctr,'\t',count,'\t',d[count])
ctr=ctr+1
if c.upper() in d:
print('CAPITAL OF',c,'is',d[c.upper()])
else:
cap=input('ENTER CAPITAL:\t')
d[c.upper()]=cap.upper()
#STUDENT DATA
def student():
d={}
for i in range(n):
name=input(…
CHOICE:1
1 INDIA DELHI
3 CHINA BEIJING
4 AUSTRALIA CANBERRA
5 CANADA OTTAWA
2) MAIN MENU
2:STUDENTS DATA
4:EMPLOYES DATA
5:EXIT
ENTER CAPITAL…