Define a function stat(gender, age, height, mass) that returns weight, meter, centimeter, and bmr, in which:Use the variables defined in the input (age, height, mass) and s_value, to implement the formula for BMR: bmr = 10.0 * mass + 6.25 * height - 5.0 * age + s_valueCreate a new variable weight that measures the mass in 斤. Use the conversion factor 1 kilogram = 2 斤.Create a new variables meter and centimeter each represented as integers. Those value should be computed by using one Python arithmetic operator on the variable heightExpected outputAssume mass = 55, height = 160, age = 22, s_value = -161, once you call the function,stat(gender, age, height, mass)The expected output should be:(110, 1, 60, 1279.0)
Question
Define a function stat(gender, age, height, mass) that returns weight, meter, centimeter, and bmr, in which:Use the variables defined in the input (age, height, mass) and s_value, to implement the formula for BMR: bmr = 10.0 * mass + 6.25 * height - 5.0 * age + s_valueCreate a new variable weight that measures the mass in 斤. Use the conversion factor 1 kilogram = 2 斤.Create a new variables meter and centimeter each represented as integers. Those value should be computed by using one Python arithmetic operator on the variable heightExpected outputAssume mass = 55, height = 160, age = 22, s_value = -161, once you call the function,stat(gender, age, height, mass)The expected output should be:(110, 1, 60, 1279.0)
Solution
Here is the Python function that meets your requirements:
def stat(gender, age, height, mass):
if gender == 'male':
s_value = 5
else:
s_value = -161
bmr = 10.0 * mass + 6.25 * height - 5.0 * age + s_value
weight = mass * 2
meter = height // 100
centimeter = height % 100
return weight, meter, centimeter, bmr
This function first checks the gender to determine the value of s_value. Then it calculates the BMR using the provided formula. It also calculates the weight in 斤 by multiplying the mass in kilograms by 2. Finally, it calculates the height in meters and centimeters using integer division and modulus operations, respectively. The function returns these four values.
Similar Questions
Create a function of name get_bmi() that receive the weight in kilograms and height in centimeter of a person and return his or her Body Mass index (BMI). The function should convert the height to meters before calculating the BMI.Height in meter = height in centimeter / 100BMI = weight in kilogram / (height in meter * height in meter)For example:Test Resultprint("BMI value:", round(get_bmi(60, 160),1))BMI value: 23.4print("BMI value:", round(get_bmi(85, 170),1))BMI value: 29.4
BMI CalculatorCreate an application which calculates BMI (Body Mass Index)Your app should have 2 input boxesTake weight in kgs from userTake height in meters from userBased on entered height and weight calculate BMI of that personHere is the formula for manually calculating BMI BMI = (weight) / (height * height)From the obtained BMI result, display whether the person isUnderWeight - bmi <= 18.4Normal Weight - bmi >= 18.5 && bmi <= 24.9Overweight - bmi >= 25 && bmi <= 29.9Obese - bmi >= 30Hint: use If conditionsSample Output
John is a fitness trainer and needs to calculate the Body Mass Index (BMI) for his clients to assess their health status. Write a program for him that takes the weight in kilograms and height in meters of a client as input, calculates their BMI, and determines if they fall within the healthy range.Note: The healthy range of BMI is 18.5 to 24.9 (both inclusive).Input format :The input consists of two double values: the weight in kilograms and the height in meters.Output format :The first line of output prints "BMI: X" where X is a double value, rounded off to two decimal places.The second line prints one of the following:If the BMI is within the valid range, print "Healthy Range".Otherwise, print "Not in Healthy Range".Refer to the sample output for formatting specificationsCode constraints :10.0 ≤ weight ≤ 300.00.00 ≤ height ≤ 3.00Sample test cases :Input 1 :65.81.75Output 1 :BMI: 21.49Healthy RangeInput 2 :124.31.87Output 2 :BMI: 35.55Not in Healthy Range
Given height and weight of a person in float, calculate Body Mass index of the person and print respective output based on calculation. Formulae for calculation: [weight (kg) / height (cm) / height (cm)] x 10,000 .For Example: weight =76.7 , height=162.2 BMI=((76.7/162.2)/162.2)X 10,000BMI=(0.4728/162.2)X 10,000 BMI=0.000291X 10,000 BMI=29.1 So, it is Overweight.Print "Underweight" or "Healthy weight" or "Overweight" or "Obesity". Below 18.5 Underweight 18.5 – 24.9 Healthy weight 25.0 – 29.9 Overweight 30.0 and Above ObesityInput Format:Accept two inputs, weight(float) and height(float)Output Format:Print "Underweight" or "Healthyweight" or "Overweight" or "Obesity"Constraints:1<=N<=10^15Sample Input 1:46.5 165.3Sample Output 1:UnderweightSample Input 2:76.7 162.2Sample Output 2:Overweight
Problem StatementBalaji wants your help to design a fitness calculator. The simple measure of body fitness is the BMI or Body Mass Index. It depends only on the height L and weight W of a person. It is defined as BMI = [weight / height2] where weight is taken in kilograms and length in meters. Four general grades are proposed:Underweight[U] - when BMI < 18.5Normal weight[N] - 18.5 <= BMI < 25.0Heavyweight [H] - 25.0 <= BMI < 30.0Overweight [O] - above or equal to 30.0Write a program that takes in the Weight (in Kg) and Length (in meters) of an individual and displays the grade as U, N, H, O.Note: Store all the variables in register memory.Input format :The first line of input consists of an integer, representing the weight.The second line consists of a double value, representing the height in meters.Output format :The output displays the grade based on the given conditions.Refer to the sample output for the formatting specifications.Code constraints :In the given scenario, the test cases will fall under the following constraints:60 ≤ weight ≤ 2001.0 ≤ height ≤ 5.0Sample test cases :Input 1 :1303.5Output 1 :UInput 2 :2002.7Output 2 :HInput 3 :902.1Output 3 :NInput 4 :741.3Output 4 :O
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.