0% found this document useful (0 votes)
6 views3 pages

Program 6. Menu Driven Code - Tuples Aim

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)
6 views3 pages

Program 6. Menu Driven Code - Tuples Aim

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/ 3

PROGRAM 6.

MENU DRIVEN CODE – TUPLES


AIM:
Using UDFs write a python code to have the following options in a menu:
i) Display words with vowels ( the function will display words having all 5
vowels in a tuple passed as parameter )
ii) Check BMI ( the function to check BMI and return OBESE /NORMAL
/UNDERWEIGHT) Kg/m2. >= 30 Obese; >25 Overweight 18.5 – 25 Normal.
<18.5 – Underweight ( the function to be checked with each element of a
nested tuple having height and weight of the person passed as parameter)
iii) Exit

PROGRAM CODING:
def tup_vow(t):
print("Words contain all 5 vowels are")
for i in t:
l=['a','e','i','o','u']
for j in i:
x=j.lower()
if x in l: l.remove(x)
if l==[]: print(i)
def bmi_chk(t):
n=len(t)
for i in range(n):
bmi=t[i][1]/t[i][0]**2
if bmi>=30.0:
print("For the given height and weight",t[i],"Obese")
elif bmi>=25.0 and bmi<30.0: #25.0<=bmi<30.0
print("For the given height and weight",t[i],"Overweight")
elif bmi>=18.5 and bmi<25.0: #18.5<=bmi<25.0
print("For the given height and weight",t[i],"Normal")
else:
print("For the given height and weight",t[i],"Underweight")
#main code
print('''Menu
1.Showing words having all 5 vowels
2.To check BMI
3.Exit''')
while True:
ch=int(input("Enter your choice"))
if ch==1:
t=()
n=int(input("enter the number of words"))
for i in range(n):
word=input("Enter a word")
t+=(word,)
tup_vow(t)
elif ch==2:
t=()
n=int(input("enter the number entries"))
for i in range(n):
w=float(input("Enter weight in Kg:"))
h=float(input("Enterheight in meter:"))
t+=((h,w,),)

bmi_chk(t)
elif ch==3:
print("BYE")
break
else: print("Invalid choice")
OUTPUT
Menu
1.Showing words having all 5 vowels
2.To check BMI
3.Exit
Enter your choice1
enter the number of words3
Enter a wordwharehousing
Enter a wordpandemonium
Enter a wordaugust
Words contain all 5 vowels are
wharehousing
pandemonium
Enter your choice2
enter the number entries3
Enter weight in Kg:45
Enterheight in meter:1.4
Enter weight in Kg:56
Enterheight in meter:1.6
Enter weight in Kg:75
Enterheight in meter:1.62
For the given height and weight (1.4, 45.0) Normal
For the given height and weight (1.6, 56.0) Normal
For the given height and weight (1.62, 75.0) Overweight
Enter your choice4
Invalid choice
Enter your choice3
BYE'''

You might also like