Finding if a given number is in a given range based on a flag Question Description:

Given a number n, return True if n is in the range 1..10, inclusive. Unless outsideMode is True, in which case return True if the number is less or equal to 1, or greater or equal to 10.
in1to10(5, False) → **True**

in1to10(11, False) → **False**

in1to10(11, True) → **True**


The link to the problem is here.
Below is my first attempt.  Please feel free to review it based on best practices, style and any other efficient solution.
def in1to10(n, outside_mode):
    if(n&gt;1 and n&lt;10):
        return not outside_mode
    else:
        return outside_mode or n is 10 or n is 1
The logic is confusing. A direct translation of the problem specification is possible, and clearer.

Let's deal with the first half of the problem:


  Given a number \$n\$, return True if \$n\$ is in the range \$1 ..10\$, inclusive.


Then it's natural to write:

def in1to10(n):
    return 1 &lt;= n &lt;= 10


Now we can deal with the second half:

def in1to10(n, outside_mode):
    if outside_mode:
        return n &lt;= 1 or n &gt;= 10
    return 1 &lt;= n &lt;= 10