Homework Help: Questions and Answers: The following equation estimates the average calories burned for a person when exercising, which is based on a scientific journal article (source):
Calories= (Age x 0.2757+ Weight 0.03295 + Heart Rate × 1.0781-75.4991) × (Time)/8.368
Write a program using inputs age (years), weight (pounds), heart rate (beats per minute), and time (minutes), respectively. Output the average calories burned for a person.
Output each floating-point value with two digits after the decimal point, which can be achieved as follows:
print (f’ Calories: {calories:.2f} calories’)
Ex: If the input is: 49 155 148 60
then the output is:
Calories: 736.21 calories
Answer:
To solve the problem step by step, let’s break it down. The task is to compute the average calories burned based on the provided formula:
Calories = ((Age×0.2757) + (Weight×0.03295) + (HeartRate×1.0781) − 75.4991) × (Time/8.368)
Steps:
- Input: Get inputs for age, weight, heart rate, and time.
- Apply Formula: Plug these values into the formula to calculate the calories burned.
- Formatting: Ensure the output is displayed with two decimal places.
# Get user inputs
age = int(input())
weight = float(input())
heart_rate = float(input())
time = float(input())
# Calculate calories using the given formula
calories = ((age * 0.2757) + (weight * 0.03295) + (heart_rate * 1.0781) - 75.4991) * (time / 8.368)
# Output the result formatted to two decimal places
print(f'Calories: {calories:.2f} calories')
Example:
Input:
49 155 148 60
Output:
Calories: 736.21 calories
Explanation:
- Age: 49
- Weight: 155 pounds
- Heart Rate: 148 bpm
- Time: 60 minutes
The formula is applied as:
Calories = ((49×0.2757) + (155×0.03295) + (148×1.0781) − 75.4991) × (608.368)
This results in approximately 736.21 calories.
Learn More: Homework Help
Q. Why were magnetic tapes used to replace punch cards in Second Generation computers?
Q. Which answer choice does NOT describe a responsibility of a safe social media user?