Skip to main content
Code Review

Return to Question

Commonmark migration
Source Link

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, 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, 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
fix title typo
Link
rolfl
  • 98.1k
  • 17
  • 219
  • 419

Finding isif a given number is in a given range based on a flag

Tweeted twitter.com/#!/StackCodeReview/status/523010271732707328
deleted 31 characters in body; edited tags
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

I am starting out on Python below is the questionQuestion Description:

Given a number nn, 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, 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
added 32 characters in body
Source Link
Phrancis
  • 20.5k
  • 6
  • 69
  • 155
Loading
Source Link
Anirudh
  • 872
  • 2
  • 13
  • 28
Loading
lang-py

AltStyle によって変換されたページ (->オリジナル) /