The following equations estimate the calories burned when exercising (source): Men: Calories = ( (Age x 0.2017) — (Weight x 0.09036) + (Heart Rate x 0.6309) — 55.0969 ) x Time / 4.184 Women: Calories = ( (Age x 0.074) — (Weight x 0.05741) + (Heart Rate x 0.4472) — 20.4022 ) x Time / 4.184 Write a program using inputs age (years), weight (pounds), heart rate (beats per minute), and time (minutes), respectively. Output calories burned for men and women. Output each floating-point value with two digits after the decimal point, which can be achieved as follows: print('Men: {:.2f} calories'.format(calories_man))

Respuesta :

Answer:

// program in Python.

#function to calaculate calories burned

def cal_burned(u_age, u_weight, heart_rate, time, gen):

   #variable

   cal = 0.0

   #for men

   if gen == 'm':

       cal = ((u_age * 0.2017) - (u_weight * 0.09036) + (heart_rate * 0.6309) - 55.0969) * time / 4.184

   #for women

   elif gen == 'f':

       cal = ((u_age * 0.074) - (u_weight * 0.05741) + (heart_rate * 0.4472) - 20.4022) * time / 4.184

#return calories burned

   return cal

#driver function

def main():

   #read age

   u_age=int(input('Enter age (years):'))

   #read weight

   u_weight=float(input('Enter weight (pounds):'))

   #read heart rate

   heart_rate=float(input('Enter heart rate (beats per minute):'))

   #read time

   time = int(input('Enter time (minutes):'))

#call function for Men

   calories_man=cal_burned(u_age,u_weight,heart_rate,time,'m')

#call function for women

   calories_women=cal_burned(u_age,u_weight,heart_rate,time,'f')

#print calories burned for Men

   print('Men: {:.2f} calories'.format(calories_man))

#print calories burned for women

   print('Men: {:.2f} calories'.format(calories_women))

#call main function

main()

Explanation:

Read age, weight, heart rate and time from user.Then call the function cal_burned() with all the input and a character parameter for men.This function will calculate  and return the total calories burned by the men.Similarly call the function again for women, Then it will return the calories burned by women.Print the calories burned by men and women.

Output:

Enter age (years):25                                                                                                      

Enter weight (pounds):180                                                                                                  

Enter heart rate (beats per minute):145                                                                                    

Enter time (minutes):50                                                                                                    

Men: 300.68 calories                                                                                                      

Men: 429.71 calories