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
Water vapor at 6 MPa, 600 degrees C enters a turbine operating at steady state and expands to 10kPa. The mass flow rate is 2 kg/
kirill115 [55]

Answer:

Explanation:

Obtain the following properties at 6MPa and 600°C from the table "Superheated water".

h_1=3658.8KL/Kg\\s_1=7.1693kJ/kg.k

Obtain the following properties at 10kPa from the table "saturated water"

h_{f2}=191.81KJ/Kg.K\\h_{fg2}=2392.1KJ/Kg\\s_{f2}=0.6492KJ/Kg.K\\s_{fg2}=7.4996KJ/Kg.K

Calculate the enthalpy at exit of the turbine using the energy balance equation.

\frac{dE}{dt}=Q-W+m(h_1-h_2)

Since, the process is isentropic process Q=0

0=0-W+m(h_1-h_2)\\h_2=h_1-\frac{W}{m}\\\\h_2=3658.8-\frac{2626}{2}\\\\=2345.8kJ/kg

Use the isentropic relations:

s_1=s_{2s}\\s_1=s_{f2}+x_{2s}s_{fg2}\\7.1693=6492+x_{2s}(7.4996)\\x_{2s}=87

Calculate the enthalpy at isentropic state 2s.

h_{2s}=h_{f2}+x_{2s}.h_{fg2}\\=191.81+0.87(2392.1)\\=2272.937kJ/kg

a.)

Calculate the isentropic turbine efficiency.

\eta_{turbine}=\frac{h_1-h_2}{h_1-h_{2s}}\\\\=\frac{3658.8-2345.8}{3658.8-2272.937}=0.947=94.7%

b.)

Find the quality of the water at state 2

since h_f at 10KPa <h_2<h_g at 10KPa

Therefore, state 2 is in two-phase region.

h_2=h_{f2}+x_2(h_{fg2})\\2345.8=191.81+x_2(2392.1)\\x_2=0.9

Calculate the entropy at state 2.

s_2=s_{f2}+x_2.s_{fg2}\\=0.6492+0.9(7.4996)\\=7.398kJ/Kg.K

Calculate the rate of entropy production.

S=\frac{Q}{T}+m(s_2-s_1)

since, Q = 0

S=m(s_2-s_1)\\=2\frac{kg}{s}(7.398-7.1693)kJ/kg\\=0.4574kW/k

6 0
3 years ago
A triangular plate with a base 5 ft and altitude 3 ft is submerged vertically in water. If the base is in the surface of water,
Scorpion4ik [409]

Answer:

Hydrostatic force = 41168 N

Explanation:

Complete question

A triangular plate with a base 5 ft and altitude 3 ft is submerged vertically in water  so that the top is 4 ft below the surface. If the base is in the surface of water, find the force against onr side of the plate. Express the hydrostatic force against one side of the plate as an integral and evaluate it. (Recall that the weight density of water is 62.5 lb/ft3.)

Let "x" be the side length submerged in water.

Then

w(x)/base = (4+3-x)/altitude

w(x)/5 = (4+3-x)/3

w(x) = 5* (7-x)/3

Hydrostatic force = 62.5 integration of  x * 4 * (10-x)/3 with limits from 4 to 7

HF = integration of 40x - 4x^2/3

HF = 20x^2 - 4x^3/9 with limit 4 to 7

HF = (20*7^2 - 4*7^(3/9))- (20*4^2 - 4*4^(3/9))

HF = 658.69 N *62.5 = 41168 N

4 0
2 years ago
When subject to an unknown torque, the shear stress in a 2 mm thick rectangular tube of dimension 100 mm x 200 mm was found to b
laila [671]

Answer:

The shear stress will be 80 MPa

Explanation:

Here we have;

τ = (T·r)/J

For rectangular tube, we have;

Average shear stress given as follows;

Where;

\tau_{ave} = \frac{T}{2tA_{m}}

A_m = 100 mm × 200 mm = 20000 mm² = 0.02 m²

t = Thickness of the shaft in question = 2 mm = 0.002 m

T = Applied torque

Therefore, 50 MPa = T/(2×0.002×0.02)

T = 50 MPa × 0.00008 m³ = 4000 N·m

Where the dimension is 50 mm × 250 mm, which is 0.05 m × 0.25 m

Therefore, A_m = 0.05 m × 0.25 m = 0.0125 m².

Therefore, from the following average shear stress formula, we have;

\tau_{ave} = \frac{T}{2tA_{m}}

Plugging in then values, gives;

\tau_{ave} = \frac{4000}{2\times 0.002 \times 0.0125} = 80,000,000 Pa

The shear stress will be 80,000,000 Pa or 80 MPa.

7 0
3 years ago
On highways, the far left lane is usually the _____. A. emergency lane B. merge lane C. slowest D. fastest
slamgirl [31]

On highways, the far left lane is usually the<u> fastest</u> moving traffic.

Answer: Option D.

<u>Explanation:</u>

For the most part, the right lane of a freeway is for entering and leaving the traffic stream. It is an arranging path, for use toward the start and end of your interstate run. The center paths are for through traffic, and the left path is for passing. On the off chance that you are not passing somebody, try not to be driving in the left path.

Regular practice and most law on United States expressways is that the left path is saved for passing and quicker moving traffic, and that traffic utilizing the left path must respect traffic wishing to surpass.

7 0
3 years ago
Read 2 more answers
Lydia is the CEO for a large pharmaceutical manufacturer. Her company is in the final stages of FDA
weqwewe [10]
OSHA inspections are generally unannounced. In fact, except in four exceptional circumstances when advance notice may be given.


It is a criminal offense for any person to give unauthorized advance notice of an OSHA inspection.
5 0
3 years ago
Other questions:
  • Suppose that the president of a small island nation has decided to increase government spending by constructing three beach reso
    11·1 answer
  • In this milestone we will create a Course class to represent a course and display its information on the screen. We will create
    9·1 answer
  • Air is compressed in the compressor of a turbojet engine. Air enters the compressor at 270 K and 58 kPa and exits the compressor
    13·1 answer
  • This problem demonstrates aliasing. Generate a 512-point waveform consisting of 2 sinusoids at 200 and 400-Hz. Assume a sampling
    8·1 answer
  • Describe a simple process
    11·1 answer
  • Saturated steam coming off the turbine of a steam power plant at 40°C condenses on the outside of a 3-cm-outer-diameter, 35-m-lo
    7·1 answer
  • ITS FOR DRIVERS ED!!
    13·2 answers
  • What substance do humans give to livestock to help them stay healthy?
    5·1 answer
  • 1. Asphyxiation is a hazard posed by Compressed Natural Gas (CNG) vehicles and can be detected when you notice
    7·1 answer
  • Quản trị học là gì ? ý nghĩa của quản trị học với thực tế xã hội
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!