Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

My program isn't performing the calculation please help. Below is the assignment and the program I am working on. Im hoping that the program I

My program isn't performing the calculation please help. Below is the assignment and the program I am working on. Im hoping that the program I included can be fixed rather than a brand new program. But I will accept all the help you can give me

Create a Python program to determine the body-mass index of a collection of six individuals. Your program should prompt for a list of six names first. Then, 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. Validate that input for height and weight are positive (using a loop). 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 another 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 displayed. The Main program should only have function calls. All the code is actually in the functions with arguments and returns. No globals. Design you functions carefully. Note: at least three loops and at least three (maybe as many as 6 or 7) functions.

def get_name_height_weight(): #lists for name and bmi name_list = [] bmi_list = [] for i in range(6): #input name and append to list name = input("Enter name : ") name_list.append(name) #input height and weight and validate if it is positive height = float(input("Enter height in inch : ")) if height<0: print("invalid height for", name[i]) weight = float(input("Enter weight in pounds : ")) if weight<0: print("invalid weight for", name[i]) return(name, height, weight)

#function to calculate BMI def get_BMI(height,weight): bmi = weight * 703 / height**2 return(bmi)

def get_bmi_status(bmi): if(bmi < 18.5): print('Underweight') elif(bmi >= 18.5 and bmi < 25): print('Normal') else: print('Overweight')

# The number of individuals in each category should be counted and displayed. bmi_status = [] all_bmi =[] for bmi in all_bmi: bmi_status.append(bmi) categories = ['Underweight','Normal','Overweight'] for category in categories: count = 0 for bmi_status in range(6): if(bmi == category): count = count + 1 print('For the category',category,'the number of individuals are: ',count) def main(): myName names,height,weight = get_name_height_weight() bmi = get_BMI(height,weight) count = get_bmi_status(bmi)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Unity From Zero To Proficiency Beginner A Step By Step Guide To Coding Your First Game

Authors: Patrick Felicia

1st Edition

1091872023, 978-1091872028

More Books

Students also viewed these Programming questions