#!/usr/local/bin/python3 class Person: def __init__(self, weight, height): self.weight = weight self.height = height def bmi(self): return BMI.calc(self) class BMI: @staticmethod def calc(person): h = person.height / 100 return person.weight / (h**2) @staticmethod def decide(person): bmi = person.bmi() print('---') print('BMI =', bmi) if bmi < 18.5: print('痩せ型') elif bmi < 25.0: print('標準') elif bmi < 30.0: print('軽度肥満') elif bmi < 35.0: print('重症肥満') else: print('超肥満') person = Person(65, 170) print(person) bmi = person.bmi() print(bmi) BMI.decide(person)