51.5k views
4 votes
Write a function test using if-else-if statements that tests the condition of a number range. If the integer number is between 1 and 3, including those numbers, it should display the message "Low". If the number is between 4 and 5, including those numbers, it should display the message, "High".

User Jawann
by
8.4k points

1 Answer

6 votes

Final answer:

The function takes an integer and uses if-else-if statements to determine if it is within specific ranges, displaying 'Low' for 1 to 3 and 'High' for 4 to 5.

Step-by-step explanation:

To create a function that tests the condition of a number range using if-else-if statements, you can write a function in a programming language such as Python. This function will check the integer number provided and display a message according to the number's range.

Here is an example of how the function might look:

def test_number_range(number):
if 1 <= number <= 3:
print("Low")
elif 4 <= number <= 5:
print("High")
else:
print("Number out of range")

When you call the function with a number, it will check if the number is between 1 and 3, including those numbers, and if so, it will display "Low". If the number is between 4 and 5, including those numbers, it will display "High". If the number does not fall within these ranges, it will display "Number out of range".

User Sudharsan Thumatti
by
9.1k points