How can i reduce the execution time of my program
#here is the simple BMI calculator program which gives your BMI and gives you target to loose/weight based on the BMI calculated. # the instance of Human class takes basically takes three arguments. # 1. Name as String # 2. height in centimeters # 3. weight in kgs class Human: def __init__(self,name,height,weight): self.name=name self.height=height self.weight=weight def bmi(self): bmi= round(float(self.weight/((self.height/100)**2)),1) return bmi # calculate the bmi based on formula= weight/(height in meters)raise to power 2) # the round method trucates the float value to one decimal place def bmirange(self,bmi): # to compute the range of BMI # BMI btw 24.9 and 18.5 is normal # BMI below 18.5 is underweight # BMI btw 25 and 29.9 is overweight # BMi above 30 is obese if((bmi <= 24.9) & (bmi > 18.5)): print("You are fit") elif (bmi<=18.5) : print("You are underweight") print ("Target : Gain ",self.goal(bmi,.1), " kg") elif ((bmi>=25) & (bmi<=29.9)): print("You are overweight") print ("Target : Loose "+str(self.goal(bmi,-.1))+ " kg") elif(bmi >= 30): print("You are obese") print ("Target : Loose "+str(self.goal(bmi,-.1))+ " kg") def goal(self,current_bmi, step): # the step argument is has two values either 0.1 in case of underweight or -0.1 in case of overweight and obese normalrange=(18.5,24.9) target=0.0 #weight=self.weight while(current_bmi not in normalrange): #here the step can be -0.1 or +0.1 based on the calcuted BMI passed from bmirange method self.weight+=step current_bmi=self.bmi() target+=float(abs(step)) return round(target,1) david= Human("David",167,89) rock= Human("Rock",189,102) print(david.name," BMI :",david.bmi()) david.