• Language

    Python

  • Description

    Create an Ideal Weight application that accepts input for:
    - A person's name
    - A person's height
    -The system of measurement they wish to use (metric or imperial).
    The program will use the person's height to calculate his/her ideal healthy weight using a formula produced from the formula for body mass index (BMI). The BMI is a statistical measurement which compares a person's weight and height.
    Though it does not actually measure the percentage of body fat, it is a useful tool to estimate a healthy body weight based on a person s height. According to the BMI, a value of 18.5 to 25 is considered healthy.
    In this program, allow the user to use either the imperial measurements or metric to calculate a healthy weight.
    Metric: Weight (kg) = height (metres) × height (metres) × 25
    Imperial: Weight (pounds) = height (inches) × height (inches) × 25 ÷ 703

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os, sys

person_name = input ('Enter the person name: ')
height = float (input ('Enter the value of height: '))
print ('Select the value of system of measurement.')
print ('\t1.- metric')
print ('\t2.- imperial')
sys.stdout.write ('\t')
system_of_measurement = 0
while system_of_measurement<1 or system_of_measurement>2:
    system_of_measurement = int (input (': '))
    if system_of_measurement<1 or system_of_measurement>2:
        sys.stdout.write ('Wrong value. Please, enter it again.')
if system_of_measurement==1:
    print ('kg')
    healthy_weight=height*height*25
else:
    print ('pounds')
    healthy_weight=height*height*25/703
if healthy_weight>25:
    print ('You have to lose weight.')
if healthy_weight>=18.5 and healthy_weight<=25:
    print ('Your weight is considered healthy.')
if healthy_weight<18.5:
    print ('You have to win weight.')
print ('Person name: ' + person_name)
print ('Value of healthy weight: ' + repr (healthy_weight))
print ()
os.system ('pause')