Finding which radiuses generate circle areas in a given tolerance

from math import pi tolerance = 0.1 target_area = 50 circle_radiuses = [3 + i * 0.1 for i in range(15)] areas = [pi*radius**2 for radius in circle_radiuses] areas_within_tolerance = [abs(area - target_area) < target_area * tolerance for area in areas] indices = [i for i, within in enumerate(areas_within_tolerance) if within] print([(circle_radiuses[k], areas[k]) for k in indices]) ''' [ (3.8, 45.36459791783661), (3.9, 47.78362426110075), (4.0, 50.26548245743669), (4.1, 52.81017250684442) ] '''