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
agasfer [191]
3 years ago
8

Code scramble: make the program sort the three numbers x, y and z into increasing order, so that x has the smallest value, y has

the next smallest value, and z has the largest value. Drag and drop with your mouse to rearrange the lines.
Engineering
1 answer:
riadik2000 [5.3K]3 years ago
3 0

Answer:

This question is taken from code scramble exercise which has scattered lines which are to be arranged by dragging and dropping with mouse to  to get the desired output in which x has the smallest value, y has the next smallest value, and z has the largest value. So the correct arrangement is as following:

tmp=max(x,y)  

x=min(x,y)  

y=tmp  

tmp=max(y,z)  

y=min(y,z)

z=tmp  

tmp=max(x,y)  

x=min(x,y)  

y=tmp

Explanation:

So the flow works as following:

First the maximum of x and y is taken and the result is stored in a temporary variable tmp which is used so that the original values do not get affected or modified by the operations performed by the functions. Lets say that x=30 y=15 and z=40

Now the max() functions returns the maximum from the values of x and y. As x=30 and y=15 so value of x is stored in tmp which is 30 as 30>15

Next the min() function finds the minimum from the values of x and y and stores the result in x. As the minimum value is 15 so this value is stored in x and now x=15

y = tmp means now the value in tmp is copied to y, So y = 30

Next the max() function finds the maximum value from the values of y and z. As y=30 and z=40 So the maximum value is 40 so tmp variable now contains the value 40.

Next the min() function finds the minimum from the values of y and z and stores the result in y. As the minimum value is 30 so this value is stored in y which means y remains 30 so, y=30

z = tmp means now the value in tmp is copied to z, So z= 40

Now the max() functions returns the maximum from the values of x and y. After the operations of above functions the new value of x and y are: x=15 and y=30 so value of y is stored in tmp which is 30 as 30>15

Next the min() function finds the minimum from the values of x and y and stores the result in x. As the minimum value is 15 so this value is stored in x and x remains: x=15

y = tmp means now the value in tmp is copied to y, So y remains: y = 30

So the final values of x, y and z are:

x = 15 y = 30 z = 40

If you want to make a program which sort the values in x, y and z then i am providing a simple Python program that serves the purpose:

x = int(input("enter first number: "))

y = int(input("enter second number: "))

z = int(input("enter third number: "))

a1 = min(x, y, z)

a3 = max(x, y, z)

a2 = (x + y + z) - a1 - a3

print("x =",a1,"y=",a2,"z=",a3)

The program asks user to enter the value for x, y and z.

Then the minimum value from the values of x,y and z is computed using min() function and the result is stored in a1. This will be the value of x. Then the maximum value from value of x,y and z is computed using max() function and the result is stored in a2. This will be the value of z. Next the statement: a2 = (x + y + z) - a1 - a3  works as following:

Lets say the values of x = 30 y = 15 and z = 40 So a1 = 15 and a2 = 40

a2 = 30 + 15 + 40 - 15 - 40

a2 = 30

This is the value of y

So  print("x = ",a1,"y = ",a2,"z = ",a3) displays the following output:

x = 15 y = 30 z = 40

You might be interested in
A displacement transducer has the following specifications: Linearity error ± 0.25% reading Drift ± 0.05%/○C reading Sensitivity
White raven [17]

Answer:

The Estimated uncertainty in a nominal displacement of 2 cm at the design stage is plus or minus 0.0124cm

Explanation:

uncertainty in a nominal displacement

= (u^2 + v^2)^(1/2)

assume from specifications that k = 5v/5cm

                                                         = 1v/cm

u^2 = (0.0025*2)^(2) + (0.005*10*2)^2 + (0.0025*2)^2

      = 0.01225v

v = 2v * 0.001

  = 0.002v

uncertainty in a nominal displacement

= (u^2 + v^2)^(1/2)

= ((0.01225)^2 + (0.002)^2)^(1/2)

= 0.0124 cm

Therefore, The Estimated uncertainty in a nominal displacement of 2 cm at the design stage is plus or minus 0.0124cm

8 0
3 years ago
Consider a Mach 4.5 airflow at a pressure of 1.25 atm. We want to slow this flow to a subsonic speed through a system of shock w
marissa [1.9K]

Answer:

a. 130.73 atm

b. 102.62 atm

c. 87.1 atm

Explanation:

See the attached pictures.

6 0
3 years ago
What is the pressure at the bottom of a 25 ft volume of hydraulic fluid with a weight density of 55 lb/ft3 a. 114.6 psi b. 1375p
Assoli18 [71]

Answer:

d) 9.55 psi

Explanation:

pressure at the bottom is =ρgh

weight density is ρg=55 lb/ft³

h=25ft

pressure at the bottom is =55\times 25

                                  =1375psf

1 ft = 12 inch

pressure at bottom =\frac{1375}{12^2}

                                = 9.55 psi

so, answer will be option (d) which is 9.55 psi

3 0
3 years ago
An engineer designs a new bus that can drive 30 miles per gallon of fuel. Which of the following was likely one of the client’s
Marat540 [252]
What are the options?
7 0
4 years ago
Read 2 more answers
Statement true about fats in food
Elodia [21]

Answer:

What that means please explain

7 0
3 years ago
Read 2 more answers
Other questions:
  • Compare automation and autonomous
    12·1 answer
  • Anyone have 11th grade engineering on odyssey ware?
    8·1 answer
  • A rigid, sealed tank initially contains 2000 kg of water at 30 °C and atmospheric pressure. Determine: a) the volume of the tank
    14·1 answer
  • 1. A fixed-geometry supersonic inlet starts at a Mach number of 3. After starting, the cruise Mach number is 2, and the operatin
    13·1 answer
  • A water jet strikes normal to a fixed plate. If diameter of the outlet of the nozzle is 8 cm,and velocity of water at the outlet
    11·1 answer
  • Given that the debouncing circuit is somewhat expensive in terms of hardware (2 NAND gates, 2 resistors, and a double-pole, sing
    9·1 answer
  • What are the 2 reasons an alignment should be done?
    13·1 answer
  • (30 pts) A simply supported beam with a span L=20 ft and cross sectional dimensions: b=14 in; h=20 in; d=17.5 in. is reinforced
    13·1 answer
  • Suppose there is a mobile application that can run in two modes: Lazy or Eager. In Lazy Mode, the execution time is 3.333 second
    11·1 answer
  • What is resonance as in ultrasound waves formation using magnetostriction method​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!