V
V
vdolzhenkov2020-08-01 15:05:28
Python
vdolzhenkov, 2020-08-01 15:05:28

The console closes immediately. What do we have to do?

Calculator that calculates body mass index. I am working with version py 3.8.

spoiler
#BMI calculation software

from colorama import init, Fore, Back, Style
init()

print(Back.GREEN + "Hi there, welcome to BMI calculation software!")
print(Back.CYAN)
weight = floot(input("What's your weight?: "))
height = floot(input("And what's your heigh?: "))
print("")

bmi = float("{0:.2f}".format(weight / ((height / 100) * (height / 100)))

print(Back.RESET + "Your  current BMI is " + str(bmi))

if( bmi<= 16 ):
    print(Back.RED + "(High body mass deficit", end = '')

if( bmi >= 16 and bmi <= 18.5 ):
    print(Back.YELLOW + "(Insufficient body weight", end = '')

if( bmi >= 18.5 and bmi <= 25 ):
    print(Back.GREEN +  "(Your weight is OK", end =  '')

if( bmi >= 25 and bmi <= 30):
    print(Back.YELLOW +  "(Excess body weight", end = '')

if( bmi >= 30 and bmi <= 35 ):
    print(Back.RED + "(Obesity of the 1 degree", end = '')

if( bmi >= 35 and  bmi <= 40 ):
    print(Back.RED + "(Obesity of the 2 degree", end = '')

if( bmi > 40 ):
    print(Back.RED + "(Obesity of the 3 degree (morbid)", end = '')

print(")", end = '')
print(Style.RESET_ALL)
input()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Karbivnichy, 2020-08-01
@vdolzhenkov

In line

bmi = float("{0:.2f}".format(weight / ((height / 100) * (height / 100)))
missing at the end of the parenthesis.
In the lines:
weight = floot(input("What's your weight?: "))
height = floot(input("And what's your heigh?: "))

typo. replace float with float.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question