Number in Range Checker

Write a Python function named in_range that checks whether a number is in a given range (Inclusive of high and low). The function should return True if the number is in the range, False otherwise.

Example 1:

Input: in_range(5, 1, 10) 

Output: True

Example 2:

Input: in_range(15, 1, 10) 

Output: False

Use comparison operators to check if the number falls within the range.

def in_range(num, low, high):
    return low <= num <= high

© Let’s Data Science

LOGIN

Unlock AI & Data Science treasures. Log in!