Python bmi calcultor
Mohammad Alsuwaidi
Posted on December 15, 2021
wrote a quick bmi calculator for imperial and metric it might not be perfect but i wanna know how can i make it better
m_or_i = int(input("Enter 1 for metric and 2 for imperial: "))
if m_or_i == 1:
h1 = float(input("Enter your height in cm: "))
h = h1 / 100
w = float(input("Enter your weight in kgs: "))
an = w / h ** 2
if an < 18.4:
print"Your bmi is:", (round(an, 1)), "which means you are under weight"
elif 18.5 <= an <= 24.9:
print"Your bmi is:", (round(an, 1)), "which means you are normal weight"
elif 25 <= an <= 29.9:
print"Your bmi is:", (round(an, 1)), "which means you are over weight"
elif 30 <= an <= 34.9:
print"Your bmi is:", (round(an, 1)), "which means you are obese class 1"
elif 35 <= an <= 39.9:
print"Your bmi is:", (round(an, 1)), "which means you are obese class 2"
elif an >= 40:
print"Your bmi is:", (round(an, 1)), "which means you are obese class 3"
elif m_or_i == 2:
h1 = float(input("Enter your height in feet: "))
h2 = float(input("Enter the inches: "))
h = h1 * 12 + h2
w = float(input("Enter your weight in pounds: "))
an = w * 703 / h ** 2
if an < 18.4:
print"Your bmi is:", (round(an, 1)), "which means you are under weight"
elif 18.5 <= an <= 24.9:
print"Your bmi is:", (round(an, 1)), "which means you are normal weight"
elif 25 <= an <= 29.9:
print"Your bmi is:", (round(an, 1)), "which means you are over weight"
elif 30 <= an <= 34.9:
print"Your bmi is:", (round(an, 1)), "which means you are obese class 1"
elif 35 <= an <= 39.9:
print"Your bmi is:", (round(an, 1)), "which means you are obese class 2"
elif an >= 40:
print"Your bmi is:", (round(an, 1)), "which means you are obese class 3"
💖 💪 🙅 🚩
Mohammad Alsuwaidi
Posted on December 15, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
beginners "🚀 From Algorithms to Applications: My Journey as a Machine Learning Developer 🤖"
June 19, 2024