It's more recent, but I wanted to do BMI calculation with python.

It's more recent, but I wanted to do BMI calculation with python. As a personal hobby. It's just a personal note.

With two python files

health_check.py


# coding: UTF-8
#Since the environment is Mac OS, UTF for Japanese support-8 
#BMI code 
#The name is health_check.py

def bmi(weight, height):
    bmi_data = []
    w = weight
    h = height
    bmi = w/(h*h)
    bmi = round(bmi, 1)
    bmi_data.append(bmi)
    if bmi<18.5:
        ans = "It is a thin type"
    elif bmi>=18.5 and bmi<25:
        ans = "Standard"
    else:
        ans = "I'm obese"
    bmi_data.append(ans)
    return bmi_data

The second is health_check_main.py.

health_check_main.py


# coding: UTF-8
# BMI health_check main
# health_check_main.py
import health_check
weight  = float(input('Please enter your weight(kg): '))
height0 = float(input('Please enter your height(cm): '))
height = height0/100
bj = health_check.bmi(weight, height)
print("----" * 10)
print("Your BMI: " + str(bj[0]) + '\n your body shape: ' + bj[1])

Execution is as follows with the bash command of the Mac OS terminal.

health_check_main.sh


$ python health_check_main.py
Please enter your weight(kg): 55
Please enter your height(cm): 160
----------------------------------------
Your BMI: 21.5
Your body shape:Standard

that's all.

Recommended Posts

It's more recent, but I wanted to do BMI calculation with python.
I wanted to solve ABC160 with Python
I wanted to solve ABC172 with Python
I want to do it with Python lambda Django, but I will stop
I wanted to solve NOMURA Contest 2020 with Python
How to do hash calculation with salt in Python
[ML Ops] I want to do multi-project with Python
I wanted to solve the Panasonic Programming Contest 2020 with Python
To do tail recursion with Python2
What to do with PYTHON release?
I want to do ○○ with Pandas
I want to debug with Python
I want to do a full text search with elasticsearch + python
I wanted to do something like an Elixir pipe in Python
I wanted to solve the ABC164 A ~ D problem with Python
I want to analyze logs with Python
I want to play with aws with python
I wanted to solve ABC159 in Python
I really wanted to copy with selenium
What skills do I need to program with the FBX SDK Python?
I want to tweet on Twitter with Python, but I'm addicted to it
I want to use MATLAB feval with python
How to do multi-core parallel processing with python
[Python] What I did to do Unit Test
Mayungo's Python Learning Episode 5: I tried to do four arithmetic operations with numbers
I just want to add scipy, but it's a messy note. Ubuntu, Python 3.
I want to send Gmail with Python, but I can't because of an error
I want to make a game with Python
I wanted to play with the Bezier curve
I tried to get CloudWatch data with Python
I tried to output LLVM IR with Python
When I connect to a remote Jupyter Server with VScode, it's remote but local
I wanted to visualize 3D particle simulation with the Python visualization library Matplotlib.
I want to use Temporary Directory with Python2
I tried to automate sushi making with python
#Unresolved I want to compile gobject-introspection with Python3
I want to solve APG4b with Python (Chapter 2)
I want to write to a file with Python
I wanted to create a dll to use a function written in C from Python with ctypes, but I had a hard time
I also wanted to check type hints with numpy
I want to handle optimization with python and cplex
I tried to implement Minesweeper on terminal with python
I tried to touch the CSV file with Python
I tried to draw a route map with Python
I tried to solve the soma cube with python
I tried to get started with blender python script_Part 02
I wanted to use the Python library from MATLAB
It's too troublesome to display Japanese with Vim's python3.
I was addicted to scraping with Selenium (+ Python) in 2020
I want to inherit to the back with python dataclass
I want to work with a robot in python.
I tried to automatically generate a password with Python3
I want to AWS Lambda with Python on Mac!
I tried to solve the problem with Python Vol.1
I made a python library to do rolling rank
I tried to analyze J League data with Python
I want to run a quantum computer with Python
I want to do something in Python when I finish
I tried to solve AOJ's number theory with Python
Do Houdini with Python3! !! !!
Numerical calculation with Python