Question Description:
Given a number
n
, returnTrue
ifn
is in the range 1..10, inclusive. UnlessoutsideMode
is True, in which case returnTrue
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>1 and n<10):
return not outside_mode
else:
return outside_mode or n is 10 or n is 1
Question Description:
Given a number
n
, returnTrue
ifn
is in the range 1..10, inclusive. UnlessoutsideMode
is True, in which case returnTrue
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>1 and n<10):
return not outside_mode
else:
return outside_mode or n is 10 or n is 1
Question Description:
Given a number
n
, returnTrue
ifn
is in the range 1..10, inclusive. UnlessoutsideMode
is True, in which case returnTrue
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>1 and n<10):
return not outside_mode
else:
return outside_mode or n is 10 or n is 1
Finding isif a given number is in a given range based on a flag
I am starting out on Python below is the questionQuestion Description:
Given a number n
n
, return TrueTrue
if nn
is in the range 1..10, inclusive. Unless "outsideMode"outsideMode
is True, in which case return TrueTrue
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. Please feel free to review it based on best practices, style and any other efficient solution.
def in1to10(n, outside_mode):
if(n>1 and n<10):
return not outside_mode
else:
return outside_mode or n is 10 or n is 1
I am starting out on Python below is the 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>1 and n<10):
return not outside_mode
else:
return outside_mode or n is 10 or n is 1
Question Description:
Given a number
n
, returnTrue
ifn
is in the range 1..10, inclusive. UnlessoutsideMode
is True, in which case returnTrue
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>1 and n<10):
return not outside_mode
else:
return outside_mode or n is 10 or n is 1