Question: Python 3.6 - Create a program that calculates target heart rates when exercising. To determine this rate, subtract your age from 220; this is called

Python 3.6 - Create a program that calculates target heart rates when exercising. To determine this rate, subtract your age from 220; this is called the maximum heart rate. Next, find your resting heart rate by taking your pulse after two minutes of resting. The upper limit of your target heart rate is 85% of the difference between your resting heart rate and maximum heart rate, and adding this to the resting heart rate. The lower limit is 65% of the difference between maximum and resting rates, added to the resting rate. For example, a 40 year old person can achieve a healthy workout by reaching a heart rate between 142 and 164 beats per minute. Write a Python program that takes a persons name and age, then prints the range of that persons target heart rate. Your program should work entirely in integers. A volunteer named Bob, who is 150 years old, was measured to have a resting heart rate of 22 beats per minute. Using this data, the program should produce an output that looks roughly like this:

TARGET TARGET HEART RATES

Fred, for your age: 150 Resting heart rate: 22 Your target heart rate is 53 to 62 beats per minute.

After the results have been shown on the screen, this same report should written to a text file in the same directory as your Python program. You should use a function to do the work of opening, writing, and closing the file.

My source code so far :

Python 3.6 - Create a program that calculates target heart rates when

def heartRate(): # First get input from the user name input("Enter your name: ") age- int (input("Enter your age: ")) restHR-int(input( "Enter your resting heart rate: ")) # Maximum heart rate max _HR 220 - age # Difference between max HR- restHR diff = (max ER-restER) totaldiff + restHR # Low range lowtotal.65 # High range high - total .85 # Print response print(str (name)+',for your age:+ str (age)) print( "Resting heart rate: "+ str (restHR)) print ( "Your target heart rate is "+ str(low) + to "+ str(high) + " beats per minute.") heartRate() heartRate) heartRate Users/PratyushaThundena/PyC Library/ Frameworks / Python . framework/Versions / 36/bin/ python Enter your name: Fred Enter your age: 120 Enter your resting heart rate: 22 Fred, for your age: 120 Resting heart rate: 2:2 Your target heart rate is 65.0 to 85.0 beats per minute

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!