I made an app program that measures BMI index by groping.
If there are any unfilled parts (especially height and weight), an error will occur.
That's why it's still incomplete, I'm sorry.
# coding: utf-8
class bodyData:
uName = ''
uSex = 0
uAge = 0
uHeight = 0
uWeight = 0
uBmi = 0
def __init__(self, uName = 'Nakamura', uSex = 0, uAge = 26):
self.uName = uName
self.uSex = uSex
self.uAge = uAge
print('Name from this: ' + str(self.uName))
#'sex: ' + str(self.uSex))
if (self.uSex == '0'):
print('sex:male')
elif (uSex == '1'):
print('sex:Female')
else:
print('sex:I do not know!!')
print('age: ' + str(self.uAge) + '\n' +
'Measures the BMI index of.')
def set_bodyData(self, uHeight, uWeight):
self.uHeight = uHeight
self.uWeight = uWeight
def result_bodyData(self, uBmi):
self.uBmi = uBmi
print('We will inform you of the result.' + '\n' +
'Full name: ' + (self.uName))
if (self.uSex == '0'):
print('sex:male')
elif (self.uSex == '1'):
print('sex:Female')
else:
print('I don't know my gender!!')
print('age: ' + str(self.uAge) + '\n' +
'height: ' + str(self.uHeight) + 'cm' + '\n' +
'body weight: ' + str(self.uWeight) + 'kg' + '\n' +
'The BMI index of the above persons is...' + '\n' +
'\n' +
str(round(self.uBmi,1)) + '\n')
def result_Bmi (self):
if (self.uBmi < 18.5):
print('I'm too thin.' + '\n' +
'Let's get fat.')
elif (18.5 < self.uBmi < 25):
print('It is a proper weight.' + '\n' +
'Let's keep it as it is.')
elif (25 < self.uBmi < 30):
print('I'm starting to gain weight.' + '\n' +
'Don't worry.')
elif (30 < self.uBmi < 35):
print('I'm fat.' + '\n' +
'Let's be aware.')
elif (35 < self.uBmi < 40):
print('Don't you notice?' + '\n' +
'You are fat')
elif (self.uBmi >= 40):
print('There is a problem.')
else:
print('The input is incorrect somewhere.' + '\n' +
'Sorry.')
uName = input('Please enter your name.' + '\n' +
'=> ')
uSex = input('Please enter your gender. 0=Male, 1=Female' + '\n' +
'=> ')
uAge = input('Please enter your age.' + '\n' +
'=> ')
bd = bodyData(uName, uSex, uAge)
uHeight = input('Please enter your height in cm.' + '\n' +
'=> ')
uWeight = input('Please enter your weight in kg.' + '\n' +
'=> ')
bd.set_bodyData(uHeight, uWeight)
uBmi = int(uWeight) / ((int(uHeight) / 100) ** 2)
bd.result_bodyData(uBmi)
bd.result_Bmi()
that's all.
Recommended Posts