Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # TODO List: GUI, Enabling user to type ft and inches whilst in imperial system
- from datetime import datetime
- name = raw_input('What is your name?: ')
- gender = raw_input('What is your gender? Male, Female or Other: ').strip()
- while gender.lower() not in ('male', 'female', 'other'):
- print('Error! Try again.')
- gender = raw_input('What is your gender? Male, Female or Other: ').strip()
- if gender.lower() not in ('male', 'female', 'other'): continue
- format_DOB = raw_input('Enter your DOB in dd/mm/yyyy format: ')
- DOB = datetime.strptime(format_DOB, '%d/%m/%Y')
- measurement = raw_input('Do you wish to use the metric system or imperial system?: ').strip()
- while measurement.lower() not in ('metric', 'imperial'):
- print('Error! Type metric or imperial only noob!!! Follow the instructions you pleb!')
- measurement = raw_input('Do you wish to use the metric system or imperial system?: ').strip()
- if measurement.lower() not in ('metric', 'imperial'): continue
- if measurement.lower() == 'metric':
- height = float(input('Enter your height in meters: '))
- weight = int(input('Enter your weight in kilograms: '))
- bmi = weight / height ** 2
- if bmi <= 18.5:
- print('Hi %r, you are %r, your age is %r and your Body Mass Index is %r therefore you are underweight') % (name, gender, (datetime.today() - DOB).days/365, bmi)
- elif bmi > 18.5 and bmi < 25:
- print('Hi %r, you are %r, your age is %r and your Body Mass Index is %r therefore you have healthy weight') % (name, gender, (datetime.today() - DOB).days/365, bmi)
- elif bmi > 25 and bmi < 30:
- print('Hi %r, you are %r, your age is %r and your Body Mass Index is %r therefore you are overweight') % (name, gender, (datetime.today() - DOB).days/365, bmi)
- elif bmi > 30:
- print('Hi %r, you are %r, your is %r and your Body Mass Index is %r therefore you are obese') % (name, gender, (datetime.today() - DOB).days/365, bmi)
- elif measurement.lower() == 'imperial':
- height = float(input('Enter your height in inches: '))
- weight = int(input('Enter your weight in pounds: '))
- bmi = (weight * 703) / height ** 2
- if bmi <= 18.5:
- print('Hi %r, you are %r, your age is %r and your Body Mass Index is %r therefore you are underweight') % (name, gender, (datetime.today() - DOB).days/365, bmi)
- elif bmi > 18.5 and bmi < 25:
- print('Hi %r, you are %r, you are %r, your age is %r and your Body Mass Index is %r therefore you have healthy weight') % (name, gender, (datetime.today() - DOB).days/365, bmi)
- elif bmi > 25 and bmi < 30:
- print('Hi %r, you are %r, your age is %r and your Body Mass Index is %r therefore you are overweight') % (name, gender, (datetime.today() - DOB).days/365, bmi)
- elif bmi > 30:
- print('Hi %r, you are %r, your age is %r and your Body Mass Index is %r therefore you are obese') % (name, gender, (datetime.today() - DOB).days/365, bmi)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement