Filtering stocks by dividend yield
First of all, I would rename the bounds to be more meaningful, from gte to min_value, and from lte to max_value.



Function 1 comes close to being a good idea, but could be implemented more smartly.  The special treatment of any falsy value (notably 0) to skip filtering is probably a bad idea.  The set intersection operation should be avoidable.

def func1_improved(data, min_value=None, max_value=None):
    if min_value is not None:
        data = {(k, v) for k, v in data if v &gt;= min_value}
    if max_value is not None:
        data = {(k, v) for k, v in data if v &lt;= max_value}
    return data.keys()




Function 2 is not equivalent to the other two: it returns a dictionary rather than a key set.  It suffers from the problem that it sometimes returns the original dictionary, and sometimes returns a copy.  It also treats 0 as a special parameter value.

def func2_improved(data, min_value=None, max_value=None):
    data = dict(data)    # Make a copy
    for k, v in data.items():
        if min_value is not None and v &lt;= min_value:
                del data[k]
        if max_value is not None and v &gt;= max_value:
                del data[k]
    return data.keys()




Function 3 is quite good, especially when formatted as a one-liner using a set comprehension:

def func3_improved(data, min_value=float('-inf'), max_value=float('inf')):
    return set(k for (k, v) in data.items() if min_value &lt;= v &lt;= max_value)


That is my recommendation.  You could eliminate some comparisons by making special cases for when min_value or max_value is missing, but I'd prefer not to ruin the elegance of the one-line solution.