Answer:
- def testInOrder(a1, a2, a3):
- aList = [a1, a2, a3]
- if(min(aList) != a1 ):
- return False
-
- if(max(aList) != a3):
- return False
-
- return True
-
- def inOrder(n1, n2, n3):
- print(testInOrder(n1, n2, n3))
-
- inOrder(2, 4, 5)
- inOrder(4, 3, 6)
- inOrder(4, 3, 2)
- inOrder(3, 5, 1)
Step-by-step explanation:
Firstly we create a driver function testInOrder that takes 3 inputs, a1, a2, and a3 (Line 1).
Since the value of a1 to a3 must be in ascending order so we can check if the a1 and a3 are the minimum and maximum number among the three, respectively. To do so, put a1, a2 and a3 into a list (Line 2). Next, we can use the min function to check if the minimum number is a1 (Line 3). If not return False (Line 4).
We can use the similar way to check if the maximum number of list is a3. If not return False (Line 6-7).
If both of the if conditions are not met, return True (Line 9).
We can test our driver function by repeatedly call the inOrder function with different sets of arguments (Line 14 - 17). We shall get the output as follows:
True
False
False
False