Ad

filterfalse can be used to generate an iterator.
filter might have been used instead but it wouldn't be as clean.

Code
Diff
  • from itertools import filterfalse
    
    def find_multiples_of_4_and_6(n):
        return filterfalse(lambda x: x%4 and x%6, range(n))
    • from itertools import filterfalse
    • def find_multiples_of_4_and_6(n):
    • for i in range(n):
    • if not (i % 4 and i % 6):
    • yield i
    • return filterfalse(lambda x: x%4 and x%6, range(n))

Used f-string and type hint where necessary.

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
    • from decimal import Decimal
    • @dataclass
    • class BMI:
    • height: int
    • weight: int
    • height: float
    • weight: float
    • @property
    • def bmi(self):
    • def bmi(self) -> float:
    • 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"
    • def calculate_bmi(self) -> str:
    • return f"there {'is no' if self.bmi < 25 else 'is'} excess weight"