I need python code for this problem. I have Pseudocode and Algorithm. My python
ID: 3725984 • Letter: I
Question
I need python code for this problem. I have Pseudocode and Algorithm. My python code has to be based on my pseudocode, If not my instructor will deduct my grade a lot. Thanks.
Algorithm:
Ask the user to enter the person weight and height
Calculate the body mass index (BMi) of that person
If body mass index is greater than or equal to 18.5 And less than or equal to 25 then
Display a message saying the person has optimal weight for their height.
Otherwise, If body mass index if less than 18.5, then display a message saying the person has underweight for their height.
Other, If body mass index if greater than 25, then display a message saying the person has overweight for their height.
Pseudocode
// Declare the variables
Declare Real weight
Declare Real height
Declare Real bodyMassIndex
//Read the weight and height of a person
Display “Enter the weight of a person in pounds.”
Input Weight
Display “Enter the height of a person in inches.”
Input height
// Calculate the body mass index (BMI)
Set bodyMassIndex = Weight * 703 / (height * height)
// Checks the body mass index of a person
If bodyMassindex >= 18.5 And bodyMassIndex <=25 Then
Display “A person has optimal weight for their
height.”
Else If bodyMassIndex < 18.5 Then
Display “A person has underweight for their
height.”
Else If bodyMassIndex > 25 Then
Display “A sperson has overweight for their
height.”
End if
Problem
“Write a program that calculates and displays a person’s body mass index (BMI). The BMI is often used to determine whether a person with a sedentary lifestyle is overweight or underweight for his or her height. A person’s BMI is calculated with the following formula:
BMI = weight x 703 / height2
where weight is measured in pounds and heightis measured in inches. The program should ask the user to enterhis/her weight and height. The program should display a message indicating whether the person has optimal weight, is underweight, or is overweight. A sedentary person’s weight is considered optimal if his or her BMI is between18.5 and 25. If the BMI is less than 18.5, the person is considered underweight. If the BMI valueis greater than 25, the person is considered overweight”
Explanation / Answer
''' In python there is no explicit declaration of variables, varialbe declaration happens when you declare a variable with value ex- x=1 //x will be type of integer y=1.0 //Y will be type of float z="aba" //z is type of string so for you problem to store real value we need to declare variable of float type with value 0.0 and letter it may be updated by user while reading input from user So to read input from user we use input() function , input() function reads the value in string format that we need to convert before assigning the variable ex- y=float(input()) and print() function is used to display message in python Please see you pseudo code line by line Sample Input: Enter the weight of a person in pounds. 144 Enter the height of a person in inches. 70 Sample Output: person has optimal weight for their height. Please test it with your given real data and let me know if there is any bug in comment section ''' #Your program start from here #Declaring the variables #Declaring variable weight weight=0.0 #Declaring real variable height height=0.0 #Declaring real variable bodyMassIndex bodyMassIndex=0.0 #Reading weight and height of person #Displaying message print("Enter the weight of a person in pounds.") #inputing weight from user weight=float(input()) #Displaying message print("Enter the height of a person in inches.") #inputing height from user height=float(input()) #Calculating the body mass index(BMI) bodyMassIndex = (weight * 703 )/ (height * height) #Checking the body mass index of a person if(bodyMassIndex >= 18.5 and bodyMassIndex 25): #Displaying print("A person has overweight for their height") #Program end hereRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.