Question

In: Computer Science

Develop a Python program to identify the body-mass index of a collection of six individuals. Your...

Develop a Python program to identify the body-mass index of a collection of six individuals. Your program should include a list of six names. Note: If you chose to prompt for the names, build the list of names first, then do the following prompt for height, weight. Using a for loop, it should successively prompt the user for the height in inches and weight in pounds of each individual. Each prompt should display the name of the individual whose height and weight is to be input. Your program should validate that input for height and weight are positive. It should call a Function that accepts the height and weight as parameters and returns the body mass index for that individual using the formula: BMindex = weight × 703 / height2. (eg. 200lb, 6ft(72in) would be: BMindex = (200*703)/(72*72) = 27.1219 ). That body mass index should then be appended to a 2nd "parallel" array. Using a second loop it should traverse the array of body mass indices and call another function that accepts the body mass index as a parameter and returns whether the individual is underweight, normal weight or overweight. The number of individuals in each category should be counted and the number in each of those categories should be displayed. You should decide on the names of the at least six individuals and the thresholds used for categorization. Note: two loops and at least two functions.  Display your name,class,date as per SubmissionRequirements by using a function.

Solutions

Expert Solution

code:

#function to caluclate BMindex

def bodymass_Index(hw):
    BMindex=[]
    #caluclating using given formula
    for i in hw:
        BMindex.append(i[1]*703/(i[0]*i[0]))
    return BMindex
#counting categories members
def caluclate(BMindex):
    underwieght=0
    normalwieght=0
    overwieght=0
    for i in BMindex:
        if i<18.5:
            underwieght=underwieght+1
        elif i>=18.5 and i<=24.9:
            normalwieght=normalwieght+1
        elif i>=25:
            overwieght=overwieght+1
    print("underwieght :",underwieght)
    print("normalwieght :",normalwieght)
    print("overwieght :",overwieght)
#list for names you can modify the names
names=['tony','captain','thor','banner','natasha','peter']
hw=[]
print("Please input hight in Inches and wieght in Pounds :")
#input
for i in names:
    h,w=-1,-1
    #validating nagative input
    while h<0 or w<0:
        h,w=map(int,input("{} :".format(i)).split())
        if h<0 or w<0:
            print("invalid data ! please re enter")
            continue
        hw.append([h,w])
BMindex=bodymass_Index(hw)
caluclate(BMindex)

sample testing:

If you have any doubt please leave a comment.

please upvote.


Related Solutions

Write a Python program to determine the body-mass index of a collection of six individuals. Your...
Write a Python program to determine the body-mass index of a collection of six individuals. Your program should include a list of six names. Using a for loop, it should successfully prompt the user for the height in inches and weight in pounds of each individual. Each prompt should include the name of the individual whose height and weight are to be input. It should call a function that accepts the height and weight as parameters and returns the body...
This involves writing a Python program to determine the body-mass index of a collection of six...
This involves writing a Python program to determine the body-mass index of a collection of six individuals. Your program should include a list of six names. Using a for loop, it should successively prompt the user for the height in inches and weight in pounds of each individual. Each prompt should include the name of the individual whose height and weight is to be input. It should call a function that accepts the height and weight as parameters and returns...
A common characterization of obese individuals is that their body mass index is at least 30...
A common characterization of obese individuals is that their body mass index is at least 30 [BMI = weight/(height)2, where height is in meters and weight is in kilograms]. An article reported that in a sample of female workers, 266 had BMIs of less than 25, 158 had BMIs that were at least 25 but less than 30, and 123 had BMIs exceeding 30. Is there compelling evidence for concluding that more than 20% of the individuals in the sampled...
A common characterization of obese individuals is that their body mass index is at least 30...
A common characterization of obese individuals is that their body mass index is at least 30 [BMI = weight/(height)2, where height is in meters and weight is in kilograms]. An article reported that in a sample of female workers, 262 had BMIs of less than 25, 156 had BMIs that were at least 25 but less than 30, and 123 had BMIs exceeding 30. Is there compelling evidence for concluding that more than 20% of the individuals in the sampled...
A common characterization of obese individuals is that their body mass index is at least 30...
A common characterization of obese individuals is that their body mass index is at least 30 [BMI = weight/(height)2, where height is in meters and weight is in kilograms]. An article reported that in a sample of female workers, 266 had BMIs of less than 25, 159 had BMIs that were at least 25 but less than 30, and 120 had BMIs exceeding 30. Is there compelling evidence for concluding that more than 20% of the individuals in the sampled...
A common characterization of obese individuals is that their body mass index is at least 30...
A common characterization of obese individuals is that their body mass index is at least 30 [BMI = weight/(height)2, where height is in meters and weight is in kilograms]. An article reported that in a sample of female workers, 264 had BMIs of less than 25, 157 had BMIs that were at least 25 but less than 30, and 121 had BMIs exceeding 30. Is there compelling evidence for concluding that more than 20% of the individuals in the sampled...
programming in Python The body mass index (BMI) is calculated as a person’s weight (in lb)...
programming in Python The body mass index (BMI) is calculated as a person’s weight (in lb) times 720, divided by the square of the person’s height (in inches). A BMI in the range 19-25, inclusive, is considered healthy. Write a program that inputs people’s weight and height, then calculates a person’s BMI and print a message telling whether they are above, within, or below the healthy range. A formula for computing Easter in the years 1982-2048, inclusive, is as follows:...
In Java, need to create a program with Body Mass Index (BMI) is a measure of...
In Java, need to create a program with Body Mass Index (BMI) is a measure of health on weight. It can be calculated by taking your weight in kilograms and dividing, by the square of your height in meters. Write a program that prompts the user to enter a weight in pounds and height in inches and displays the BMI. Note one pound is 0.45359237 kilograms and one inch is 0.0254 meters. Here is a sample run: Enter weight in...
Using class, write a program that: Body Mass Index (BMI) calculation - write a program that...
Using class, write a program that: Body Mass Index (BMI) calculation - write a program that takes users' input (weight and Height) and calculates the BMI. If the result is less than 18.5 display "you are underweight", if the result is greater than 18.5 display "you have a normal weight", if the result is greater than 24.9 display "your weight is considered overweight", and the result is greater than 30 display "your weight is considered as obese" (BMI = 703...
USE Python 3, please type thanks! Write a Python 3 program to calculate the Body Mass...
USE Python 3, please type thanks! Write a Python 3 program to calculate the Body Mass Index (BMI) of a person if they enter their weight and their height to your program. Check out the formula here: http://www.freebmicalculator.net/calculate-bmi.php Your program should first print "Body Mass Index Calculator" The program will then ask the user if they want to enter Metric Units or English Units. Using the appropriate formula (see link above) calculate their BMI. Depending on their BMI show their...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT