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
Indentify the common types of conductors used for: a. Distribution lines (33kV and below) b. Transmission lines (66kV and above)
fiasKO [112]
Wassup my big boy James with the Ghent branew air fork one nigh
8 0
3 years ago
Two soils are fully saturated with liquid (no gas present) and the soils have the same void ratio. One soil is saturated with wa
mariarad [96]

Answer:

water sample have more water content

Explanation:

given data

soil 1 is saturated with  water

unit weight of water = 1 g/cm³

soil 2 is saturated with alcohol

unit weight of alcohol  = 0.8 g/cm³

solution

we get here water content that is express as

water content = S_s \times \gamma _w   ....................1

here soil is full saturated so S_s is 100% in both case

so put here value for water

water content = 100 % ×  1

water content = 1 g

and

now we get for alcohol that is

water content  = 100 % × 0.8

water content  = 0.8 g

so here water sample have more water content

5 0
4 years ago
What is the first thing to do when you make a three-point turn?.
Jlenok [28]

Answer:

1. Move as far right as possible, check traffic, and signal a left turn.

2. Turn the steering wheel sharply to the left and move forward slowly.

3. Shift to reverse, turn your wheels sharply to the right, check traffic, and back your vehicle to the right curb, or edge of roadway.

5 0
3 years ago
A circular ceramic plate that can be modeled as a blackbody is being heated by an electrical heater. The plate is 30 cm in diame
denis23 [38]

Answer:

Q = 125.538 W

Explanation:

Given data:

D = 30 cm

Temperature T_\infity = 15 degree celcius

T_S =  220 + 273 = 473 K

Heat coefficient = 12 W/m^2 K

Efficiency 80% = 0.8

Q = hA(T_S - T_{\infty}) \eta

= 12(\frac{\pi}{4} 0.3^2) (473 - 288) 0.8

Q = 125.538 W

5 0
3 years ago
A generator operating at 50 Hz delivers 1 pu power to an infinite bus through a transmission circuit in which resistance is igno
olga55 [171]

Answer:

critical clearing angle = 70.3°

Explanation:

Generator operating at = 50 Hz

power delivered = 1 pu

power transferable when there is a fault = 0.5 pu

power transferable before there is a fault = 2.0 pu

power transferable after fault clearance = 1.5 pu

using equal area criterion to determine the critical clearing angle

Attached is the power angle curve diagram and the remaining part of the solution.

The power angle curve is given as

= Pmax sinβ

therefore :  2sinβo = Pm

                   2sinβo = 1

                   sinβo = 0.5 pu

                   βo = sin^{-1} (0.5) = 30⁰

also ;   1.5sinβ1 = 1

               sinβ1 = 1/1.5

               β1 = sin^{-1} (\frac{1}{1.5} ) = 41.81⁰

∴ βmax = 180 - 41.81  = 138.19⁰

attached is the remaining solution

The critical clearing angle = cos^{-1} 0.3372  ≈ 70.3⁰

3 0
3 years ago
Other questions:
  • A feeder is supplying a 125-ampere, 240-volt panelboard in a multifamily dwelling. The conductors will be THHN aluminum conducto
    10·1 answer
  • Fin efficiency is defined in relation to the maximum possible heat transfer rate from the fin for given convective conditions. T
    10·1 answer
  • A six-lane multilane highway (three lanes in each direction) has a peak-hour factor of 0.90, 11-ft lanes with a 4-ft right-side
    11·1 answer
  • What does the branch of physics include
    13·1 answer
  • Problem 5.024 A power cycle receives 1000 Btu by heat transfer from a reservoir at 1500°F and discharges energy by heat transfer
    13·1 answer
  • Whatever they said bbbbbbbbbbbbbbbbbb
    6·2 answers
  • Plzzzzz help ASAP 50 points for the answer
    7·1 answer
  • 48/64 reduced to its lowest term
    5·2 answers
  • 6. Which of the following is considered a major disqualifying offense?
    9·2 answers
  • A programmable integrated circuit (PIC) is another name for a microcontroller.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!