Skip to main content

Define a function to calculate BMI

 # Exercise program in Python


# Define a function to calculate BMI

def calculate_bmi(weight, height):

    bmi = weight / (height ** 2)

    return bmi


# Define a function to determine BMI category

def determine_category(bmi):

    if bmi < 18.5:

        return "Underweight"

    elif bmi < 25:

        return "Normal weight"

    elif bmi < 30:

        return "Overweight"

    else:

        return "Obese"


# Prompt user to enter weight in kg and height in meters

weight = float(input("Enter your weight in kg: "))

height = float(input("Enter your height in meters: "))


# Calculate BMI and determine category

bmi = calculate_bmi(weight, height)

category = determine_category(bmi)


# Print results

print("Your BMI is:", bmi)

print("Your BMI category is:", category)


Comments

Popular posts from this blog

What is AI in python

 AI (Artificial Intelligence) is a field of computer science that involves the development of intelligent machines that can perform tasks that typically require human-like intelligence, such as visual perception, speech recognition, decision making, and natural language processing. Python is one of the most popular programming languages used in AI development because of its simplicity, flexibility, and powerful libraries. Python has several libraries and frameworks that make it easy to develop AI applications. Some of the most popular AI libraries in Python include: 1. TensorFlow: TensorFlow is a popular open-source machine learning library developed by Google that allows developers to build and train machine learning models easily. 2. Keras: Keras is a high-level neural networks API, written in Python and capable of running on top of TensorFlow, CNTK, or Theano. 3. PyTorch: PyTorch is a popular open-source machine learning library developed by Facebook that allows developers to bu...

DEEP LEARNING IN PYTHON

 Deep learning (DL) is a subfield of machine learning that involves the development of algorithms and models that can learn and make predictions based on complex and large datasets. Python is one of the most popular programming languages for deep learning due to its simplicity, flexibility, and powerful libraries. Python has several libraries and frameworks that make it easy to develop and implement deep learning algorithms. Some of the most popular deep learning libraries in Python include: 1. TensorFlow: TensorFlow is an open-source machine learning library developed by Google that allows developers to build and train deep learning models easily. It includes a wide range of high-level APIs and tools for building and deploying deep learning models. 2. Keras: Keras is a high-level neural networks API, written in Python and capable of running on top of TensorFlow, CNTK, or Theano. It provides a simple and intuitive way to build deep learning models, making it an excellent choice for...