6. Write a python program generate a function to identify whether the specified number is in the range of initial value, list_a in the following output.
The output is:
list_a = [1, 2, 3, 4, 5, 6, 7, 8]
First number: 5
Second number: 9
Expected Answer:
First answer: 5 is in the range
Second number: The number 9 is outside the given range.
Sample Answer(First number: 5):
def input_n(number): if number in range(1,9): print( " %s is in the range"%str(number)) else : print("The number %s is outside the given range."%str(number)) input_n(5)
Sample Answer(Second number: 9):
def input_n(number): if number in range(1,9): print( " %s is in the range"%str(number)) else : print("The number %s is outside the given range."%str(number)) input_n(9)
More Exercises:
Python String ExercisesMore Numpy Exercises:
Numpy String ExercisesMore Pandas Exercises:
Pandas Series ExercisesMore Tutorials:
Python Installation - Linux (Ubuntu)