168k views
5 votes
Create a program that outputs BMI in Python Please write it out in Psuedocode first

Then create the program in Python Code
---------------------------------------- -
These must be created using functions
There must be comments on every function and also on the variables when they are defined
In the psuedocode, please record errors you come across and record it
-------------------------------------------------
It must describe what BMI is to the user and how it is calculated
-It must use height in M and weight in KG from user input
-It must round the BMI to 2 decimal places
-It must have else-if statements that check what range of the BMI the BMI is in
-It must output the total BMI and the range the user is in, and output the steps of the problem is it does them (such as "Calculating BMI....")
-It must have a paragraph of pre-defined suggestions credited to credible sources for how to lose/maintain/gain weight depending on the user's weight
-Ask the user if they are sedentary or not sedentary, and compare it to BMI. If they are sedentary and obese, suggest getting more exercise and vice versa

User Rabs G
by
8.3k points

1 Answer

5 votes

Final answer:

The student is tasked to create a Python program to calculate and categorize BMI, provide health suggestions, and consider activity levels. The program shall explain BMI, calculate it using user inputs, classify the BMI result, and offer tailored health advice. Functions will guide the users through the process in an interactive manner.

Step-by-step explanation:

To calculate Body Mass Index (BMI), you'll create a Python program using functions, following a clear psuedocode plan. The purpose of BMI is to estimate the fat content of the body, which is important for assessing health risks. Your program will walk users through the process of calculating their BMI using their weight in kilograms and height in meters and provide suggestions based on the result.

Pseudocode

Define a function to explain what BMI is

Define a function to get user's height and weight inputs

Define a function to calculate BMI

Define a function to categorize BMI and provide health suggestions

Define a function to adjust suggestions for sedentary lifestyle

Call the functions in order and display the results

Python Code

#Define a function to calculate BMI

def calculate_bmi(weight, height):
return round(weight / (height ** 2), 2)

#Define a function to categorize BMI and provide suggestions

def categorize_bmi(bmi):
if bmi < 18.5:
return 'Underweight'
elif bmi < 25:
return 'Normal weight'
elif bmi < 30:
return 'Overweight'
else:
return 'Obese'

The program will also include functions for user input and explaining BMI, also incorporating lifestyle factors into the health suggestions provided, such as encouraging sedentary obese individuals to exercise more.

User Ramit
by
8.5k points