Sunday, December 31, 2017

Body mass index calculator

In this case, we are going to see how to calculate a person's body mass index.
The formula to calculating it is:
So the code I made is this:

 p=int(input('Tell me your weight.(kg)'))  
 x=int(input('Tell me your height.(cm)'))  
 e=(x/100)**2  
 r=p/e  
 if r<=25:  
   print('Your body mass index is',round(r),'and you are thin.')  
 elif r>=30:  
   print('Your body mass index is',round(r),'and you are fat.')  
 else:  
   print('Your body mass index is',round(r),'and you are normal.')  


  • First to know the person's mas weight and height we ask the using input
  • Then I do the operations for height: pass the cm to m and square it
  • Do the rest of the operations
  • And depending on your number giving the result 
An example of what the running code would look like:


Sources:
The source to all the mathematical values are in Wikipedia

No comments:

Post a Comment