Ad

from dataclasses import dataclass
@dataclass
class BMI:
height: float
weight: float
@property
def bmi(self) -> float:return self.weight / (self.height ** 2)
def calculate_bmi(self) -> str:return f"there {'is no' if self.bmi < 25 else 'is'} excess weight"

Code
Diff
  • from dataclasses import dataclass
    @dataclass
    class BMI:
        height: float
        weight: float
        @property
        def bmi(self) -> float:return self.weight / (self.height ** 2)
        def calculate_bmi(self) -> str:return f"there {'is no' if self.bmi < 25 else 'is'} excess weight"
    • from dataclasses import dataclass
    • @dataclass
    • class BMI:
    • height: float
    • weight: float
    • @property
    • def bmi(self) -> float:
    • return self.weight / (self.height ** 2)
    • def calculate_bmi(self) -> str:
    • return f"there {'is no' if self.bmi < 25 else 'is'} excess weight"
    • def bmi(self) -> float:return self.weight / (self.height ** 2)
    • def calculate_bmi(self) -> str:return f"there {'is no' if self.bmi < 25 else 'is'} excess weight"