Write a Python function to check whether a number is in a given range


Introduction

Write a Python function to check whether a number is in a given range. I have used python 3.7 compiler for debugging purpose.


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

  1. def test_range(n):
  2. if n in range(10,20):
  3. print( "Number %s is in the range"%str(n))
  4. else :
  5. print("The number is outside the given range.")
  6. test_range(15)

Result

python language techstudy.org

     





Related Topics




Popular Posts