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

INTRODUCTION TO PYTHON

Python is a high-level, interpreted programming language that was first released in 1991. It has gained immense popularity in the world of software development over the years because of its simple and easy-to-read syntax. Python is a versatile language that can be used for a wide range of applications, including web development, data analysis, artificial intelligence, and scientific computing. One of the key features of Python is its ease of use. Python code is easy to read and write, which makes it ideal for beginners who are just starting to learn programming. The language has a straightforward syntax that resembles English, which makes it more accessible to people without a technical background. Python code is also concise and expressive, which means that it can accomplish a lot with just a few lines of code. Python is an interpreted language, which means that code written in Python is executed directly by the interpreter without the need for a separate compilation step. This makes

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 build

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 and e