Skip to content

Commit

Permalink
Merge pull request #150 from Sumith540/main
Browse files Browse the repository at this point in the history
Created BMI calculator
  • Loading branch information
Ayu-hack authored Oct 8, 2024
2 parents 983783f + dbba6c6 commit d1abefc
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions BMI calculator
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
def calculate_bmi(weight, height):
"""Calculate and return the BMI."""
bmi = weight / (height ** 2)
return bmi

def get_bmi_category(bmi):
"""Determine the BMI category based on the BMI value."""
if bmi < 18.5:
return "Underweight"
elif 18.5 <= bmi < 24.9:
return "Normal weight"
elif 25 <= bmi < 29.9:
return "Overweight"
else:
return "Obesity"

def main():
print("Welcome to the BMI Calculator!")

# Get user input for weight and height
weight = float(input("Enter your weight in kilograms: "))
height = float(input("Enter your height in meters: "))

# Calculate BMI
bmi = calculate_bmi(weight, height)

# Get BMI category
category = get_bmi_category(bmi)

# Display the result
print(f"Your BMI is: {bmi:.2f}")
print(f"You are classified as: {category}")

if __name__ == "__main__":
main()

0 comments on commit d1abefc

Please sign in to comment.