1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
zysi [14]
3 years ago
12

Assume you need to test a function named inOrder. The function inOrder receives three int arguments and returns true if and only

if the arguments are in non-decreasing order: that is, the second argument is not less than the first and the third is not less than the second. Write the definition of driver function testInOrder whose job it is to determine whether inOrder is correct. So testInOrder returns true if inOrder is correct and returns false otherwise. . For the purposes of this exercise, assume inOrder is an expensive function call, so call it as few times as possible!
Computers and Technology
1 answer:
Karo-lina-s [1.5K]3 years ago
8 0

Answer:

  1. def testInOrder(a1, a2, a3):
  2.    aList = [a1, a2, a3]
  3.    if(min(aList) != a1 ):
  4.        return False  
  5.    
  6.    if(max(aList) != a3):
  7.        return False  
  8.    
  9.    return True  
  10. def inOrder(n1, n2, n3):
  11.    print(testInOrder(n1, n2, n3))
  12. inOrder(2, 4, 5)
  13. inOrder(4, 3, 6)
  14. inOrder(4, 3, 2)
  15. inOrder(3, 5, 1)

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

You might be interested in
One of the most obvious initial changes in windows vista is the ____ interface
lana [24]
Answer choices are not provided, but I would go for "Aero."
8 0
3 years ago
An increase in Consumption will ___________ in the Classical Model of Aggregate Demand.
Step2247 [10]
The answer to your question is b
8 0
3 years ago
4.
marshall27 [118]

Answer: c

Explanation:

5 0
3 years ago
Drag the tiles to the boxes to form correct pairs.
Sergio [31]

Answer:

An overhead projector: requires slides to project images

A laptop: requires an external monitor to project high-resolution images

A computer: requires a CD-ROM drive to run presentation CDs

An external monitor: requires a port to connect to the laptop

Explanation:

The correct pair has been formed above. An overhead projector requires the slides for projecting images. A Laptop for projecting high-resolution images requires an external monitor. And a computer requires a CD-ROM drive for running presentation CDs, and an external monitor requires a port to a port which can be an HDMI port to connect to a laptop.

8 0
3 years ago
3. Which of the following is most likely fake news?
ahrayia [7]

Answer:

C. An article that tries to sell you miracle weight loss pills

7 0
3 years ago
Other questions:
  • How can i put this sign in my keybord?<br><br> :::::<br> ^<br> Here is the sign
    8·1 answer
  • Long-tail keywords are:
    9·1 answer
  • Given a variable s associated with a str, write an expression whose value is a str that is identical except that all the letters
    15·1 answer
  • Top Down Design makes it easier to solve a problem by:___________
    10·1 answer
  • The idea of supply and demand is based on the development of
    10·2 answers
  • If you were infiltrating a network (10.16.0.0/16), and searching for vulnerabilities (while trying to remain undetected), why wo
    11·2 answers
  • Difference between second and third generation of computer<br>​
    14·1 answer
  • What is the biggest problem with technology today?
    10·1 answer
  • PLEASE HELP THIS IS DUE TODAY!! WILL MARK BRAINLIEST!!
    13·2 answers
  • Read the following code:
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!