Ad

using datalass

Code
Diff
  • from dataclasses import dataclass
    from decimal import Decimal
    
    @dataclass
    class BMI:
        height: int
        weight: int
        
        @property
        def bmi(self):
            return self.weight / (self.height ** 2)
    
        def calculate_bmi(self):
            return "there is no excess weight" if self.bmi < 25 else "there is excess weight"
    • class BMI:
    • def __init__(self, height, weight):
    • self.height = height
    • self.weight = weight
    • from dataclasses import dataclass
    • from decimal import Decimal
    • @dataclass
    • class BMI:
    • height: int
    • weight: int
    • @property
    • def bmi(self):
    • return self.weight / (self.height ** 2)
    • def calculate_bmi(self):
    • return "there is no excess weight" if self.bmi < 25 else "there is excess weight"