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...

Types of python

 Python is a versatile and powerful programming language that can be used for a wide range of applications. Here are some popular Python topics that you can explore: 1. Web Development with Python: Python has become a popular choice for web development, thanks to its ease of use and the availability of frameworks such as Django and Flask. These frameworks make it easy to build web applications quickly and efficiently. 2. Data Analysis with Python: Python is also an excellent choice for data analysis because of its powerful data manipulation libraries, such as NumPy and Pandas. These libraries allow you to manipulate and analyze data in a variety of formats, making it easier to draw insights from your data. 3. Machine Learning with Python: Python has become the go-to language for machine learning because of its extensive library of machine learning frameworks, including TensorFlow, Keras, and PyTorch. These frameworks make it easy to build and train machine learning models quickly a...

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...