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
Using the Rayleigh criterion, calculate the minimum feature size that can be resolved in a system with a 0.18 NA lens when g-lin
Vladimir79 [104]

Answer:

a)

# for a g line, R = 1.211 μm

# for an I-line, R = 1.013 μm

b)

# for a g line, R = 0.726 μm

# for an I-line, R = 0.243 μm

c)

# for a g line, R = 0.605 μm

# for an I-line, R = 0.608 μm

Explanation:

We know that;

Rayleigh Resolution R = 0.5 × λ/NA

for a g line, λ = 436 nm

for an I-line λ = 365 nm

a)

Now when NA = 0.18

# for a g line, λ = 436 nm

R = 0.5 × 436/0.18 =  1.211 μm

# for an I-line λ = 365 nm

R = 0.5 × 365/0.18 =  1.013 μm

b)

when NA = 0.30

# for a g line, λ = 436 nm

R = 0.5 × 436/0.30 =  0.726 μm

# for an I-line λ = 365 nm

R = 0.5 × 365/0.30 =  0.243 μm

c)

when NA = 0.36

# for a g line, λ = 436 nm

R = 0.5 × 436/0.36 =  0.605 μm

# for an I-line λ = 365 nm

R = 0.5 × 365/0.30 =  0.608 μm

6 0
3 years ago
The current entering the positive terminal of a device is i(t)= 6e^-2t mA and the voltage across the device is v(t)= 10di/dtV.
liberstina [14]

Answer:

a) 2,945 mC

b) P(t) = -720*e^(-4t) uW

c) -180 uJ

Explanation:

Given:

                           i (t) = 6*e^(-2*t)

                           v (t) = 10*di / dt

Find:

( a) Find the charge delivered to the device between t=0 and t=2 s.

( b) Calculate the power absorbed.

( c) Determine the energy absorbed in 3 s.

Solution:

-  The amount of charge Q delivered can be determined by:                      

                                       dQ = i(t) . dt

                  Q = \int\limits^2_0 {i(t)} \, dt = \int\limits^2_0 {6*e^(-2t)} \, dt = 6*\int\limits^2_0 {e^(-2t)} \, dt

- Integrate and evaluate the on the interval:

                   = 6 * (-0.5)*e^-2t = - 3*( 1 / e^4 - 1) = 2.945 C

- The power can be calculated by using v(t) and i(t) as follows:

                 v(t) = 10* di / dt = 10*d(6*e^(-2*t)) /dt

                 v(t) = 10*(-12*e^(-2*t)) = -120*e^-2*t mV

                 P(t) = v(t)*i(t) = (-120*e^-2*t) * 6*e^(-2*t)

                 P(t) = -720*e^(-4t) uW

- The amount of energy W absorbed can be evaluated using P(t) as follows:

                 W = \int\limits^3_0 {P(t)} \, dt = \int\limits^2_0 {-720*e^(-4t)} \, dt = -720*\int\limits^2_0 {e^(-4t)} \, dt

- Integrate and evaluate the on the interval:

                  W = -180*e^-4t = - 180*( 1 / e^12 - 1) = -180uJ

6 0
4 years ago
What is the locating position of the land field?​
Ivahew [28]

Any point on earth can be located by specifying its latitude and longitude, including Washington, DC, which is pictured here. Lines of latitude and longitude form an imaginary global grid system, shown in Fig. 1.17. Any point on the globe can be located exactly by specifying its latitude and longitude.

4 0
3 years ago
A rigid bar pendulum is attached to a cart, which moves along the horizontal plane. The rigid bar has a center of mass at L/2. T
Vikentia [17]

Answer:

See the attached picture for answer.

Explanation:

See the attached picture for explanation.

4 0
4 years ago
For arwa and yeahahhahahhhhhhhhhhhhh
Setler79 [48]
Chicken nugget baby sauce
3 0
3 years ago
Read 2 more answers
Other questions:
  • The spring has a stiffness k=200 N/m and is unstretched when the 25 kg block is at A. Determine the acceleration of the block wh
    6·1 answer
  • Consider a very long, slender rod. One end of the rod is attached to a base surface maintained at Tb, while the surface of the r
    8·1 answer
  • Write the chemical equation of the polymerization reaction to synthesize PS
    14·1 answer
  • (25) Consider the mechanical system below. Obtain the steady-state outputs x_1 (t) and x_2 (t) when the input p(t) is the sinuso
    9·1 answer
  • What should -7/56 BE DIVIDE TO GET -1/8​
    14·2 answers
  • The ampere draw of a 5000 watt electric heater used on 120 volts is
    12·1 answer
  • Maggie discovered that a pipe in her basement has sprung a leak. She calls a plumber but in the meantime she grabs a roll of duc
    11·1 answer
  • Two identical bulbs in parallel in a radio create a total resistance of 15 ohms in the circuit. What's the resistance of each of
    6·1 answer
  • Cody’s car accelerates from 0m/s to 45 m/s northward in 15 seconds. What is the acceleration of the car
    14·1 answer
  • Find the altitude of the right cylinder of maximum convex surface that can be inscribed in a given sphere.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!