mardi 24 novembre 2020

Python While Loop Stopping at IF statement [closed]

Creating a loop for the Karvonen Formula which calculates maximum heart rates at various workout intensities. It is supposed to add 0.05 to the starting intensity rate of 0.5 until it gets to .95 at which point it should complete. However, it runs until it gets to the if statement no errors.

#Karvonon Formula loop
intensity = float(0.50)
while (intensity) <= (0.95):

    print ('\n')
    print ('Exercise Intensity Heart Rates:')
    print ('Intensity       Max Heart Rate')

    maximum_heart_rate = float(220) - float(age)
    heart_rate_reserve = float(maximum_heart_rate) - float(heart_rate)
    maximum_target_zone = float(heart_rate_reserve) * (intensity)
    target_training_zone = float(maximum_target_zone) + float(heart_rate)
    answer = target_training_zone

    print (intensity,'           ', answer)

    if intensity < 0.95:
        intensity == float(intensity) + (0.05)
    elif intensity >= 0.95:
        break

Aucun commentaire:

Enregistrer un commentaire