def get_age():
    age = int(input())
    if age < 18 or age > 75:
        raise ValueError("Invalid age.")
    return age


def fat_burning_heart_rate(age):
    heart_rate = 0.70 * (220 - age)
    return heart_rate


if __name__ == "__main__":
    try:
        age = get_age()
        rate = fat_burning_heart_rate(age)
        print(f"Fat burning heart rate for a {age} year-old: {rate:.1f} bpm")
    except ValueError as excpt:
        print(excpt)
        print("Could not calculate heart rate info.")

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: