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
Paraphin [41]
3 years ago
7

A manager has a list of items that have been sorted according to an item ID. Some of them are duplicates. She wants to add a cod

e to the database that assigns a 1 to the item if it is​ unique, and if there are​ duplicates, assigns the number of the duplicate. An example is shown below. The first two items are​ unique, so the repeat code is 1.​ However, Item ID 37699 is listed six​ times, so the codes are assigned from 1 to​ 6, and so on. Explain how to assign the correct code using an IF statement.
Engineering
1 answer:
ruslelena [56]3 years ago
6 0

Answer:

The solution code is written in Python:

  1. items = [{"id": 37697, "code": ""},{"id": 37698, "code": ""},{"id": 37699, "code": ""},{"id": 37699, "code": ""}, {"id": 37699, "code": ""},
  2. {"id": 37699, "code": ""},{"id": 37699, "code": ""},{"id": 37699, "code": ""},{"id": 37700, "code": ""} ]
  3. items[0]["code"] = 1
  4. for i in range(1, len(items)):
  5.    if(items[i]["id"] == items[i-1]["id"]):
  6.        items[i]["code"] = items[i-1]["code"] + 1
  7.    else:
  8.        items[i]["code"] = 1
  9. print(items)

Explanation:

Firstly, let's create a list of dictionary objects. Each object holds an id and a code (Line 1-2). Please note all the code is initialized with zero at the first beginning.

Next, we can assign 1 to the <em>code</em> property of items[0] (Line 4).

Next, we traverse through the items list started from the second element (Line 6). We set an if condition to check if the current item's id is equal to the previous item (Line 7). If so, we assign the previous item's code + 1 to the current item's code (Line 8). If not, we assign 1 to the current item's code (Line 10).

At last, we print out the item (Line 12) and we shall get

[{'id': 37697, 'code': 1}, {'id': 37698, 'code': 1}, {'id': 37699, 'code': 1}, {'id': 37699, 'code': 2}, {'id': 37699, 'code': 3}, {'id': 37699, 'code': 4}, {'id': 37699, 'code': 5}, {'id': 37699, 'code': 6}, {'id': 37700, 'code': 1}]

 

You might be interested in
Compact fluorescent bulbs are much more efficient at producing light than are ordinary incandescent bulbs. They initially cost m
Ilia_Sergeevich [38]

Answer:

ordinary bulb total cost is $39.54

fluorescent bulb total cost is $13.05

amount save = 39.54 - 13.05 = $26.49

resistance = 626.1 ohm

Explanation:

in the 1st part

bulb on time = 3 year = 4380 hours

life of bulb = 750 h

so number of bulb required = \frac{4380}{750}

number of bulb required = 6

cost of 6 bulb is = 6 × 0.75 = $4.5

so

cost of operation is = 100 × 4380 × \frac{0.08}{1000}

cost of operation = $35.04

so total cost will be = $4.5 + $35.04  = $39.54

and

when compare with florescent bulb

time = 3 year = 4380 h

life of bulb = 10000 h

so number of bulb required = \frac{4380}{10000}

number of bulb required = 0.43 = 1

cost of 6 bulb is = 1 × 5 = $5

so

cost of operation is = 23 × 4380 × \frac{0.08}{1000}

cost of operation = $8.05

so total cost will be = $5 + $8.05  = $13.05

in part 2nd

total amount save while compare bulb is

amount save = 39.54 - 13.05 = $26.49

and in part 3rd

resistance of bulb is

resistance = \frac{v^2}{P}

resistance = \frac{120^2}{23}

resistance = 626.1 ohm

6 0
3 years ago
Ben İngiliz oldum düzelte bilirmiyim
Lelu [443]

Answer:

What laguange is that?

Explanation:

7 0
3 years ago
Steam enters a steady-flow adiabatic nozzle with a low inlet velocity (assume ~0 m/s) as a saturated vapor at 6 MPa and expands
Sergio [31]
Yea bro I don’t really know
7 0
2 years ago
Air enters a control volume operating at steady state at 1.2 bar, 300K, and leaves at 12 bar, 440K, witha volumetric flow rate o
topjm [15]

Answer:

Heat transfer = 2.617 Kw

Explanation:

Given:

T1 = 300 k

T2 = 440 k

h1 = 300.19 KJ/kg

h2 = 441.61 KJ/kg

Density = 1.225 kg/m²

Find:

Mass flow rate = 1.225 x [1.3/60]

Mass flow rate = 0.02654 kg/s

mh1 + mw = mh2 + Q

0.02654(300.19 + 240) = 0.02654(441.61) + Q

Q = 2.617 Kw

Heat transfer = 2.617 Kw

4 0
3 years ago
H2O enters a conical nozzle, operates at a steady state, at 2 MPa, 300 oC, with the inlet velocity 30 m/s and the mass flow rate
Colt1911 [192]

Answer:

The flow velocity at outlet is approximately 37.823 meters per second.

The inlet radius of the nozzle is approximately 0.258 meters.

Explanation:

A conical nozzle is a steady state device used to increase the velocity of a fluid at the expense of pressure. By First Law of Thermodynamics, we have the energy balance of the nozzle:

Energy Balance

\dot m \cdot \left[\left(h_{in}+\frac{v_{in}^{2}}{2} \right)-\left(h_{out}+\frac{v_{out}^{2}}{2} \right)\right]= 0 (1)

Where:

\dot m - Mass flow, in kilograms per second.

h_{in}, h_{out} - Specific enthalpies at inlet and outlet, in kilojoules per second.

v_{in}, v_{out} - Flow speed at inlet and outlet, in meters per second.

It is recommended to use water in the form of superheated steam to avoid the appearing of corrosion issues on the nozzle. From Property Charts of water we find the missing specific enthalpies:

Inlet (Superheated steam)

p = 2000\,kPa

T = 300\,^{\circ}C

h_{in} = 3024.2\,\frac{kJ}{kg}

\nu_{in} = 0.12551\,\frac{m^{3}}{kg}

Where \nu_{in} is the specific volume of water at inlet, in cubic meters per kilogram.  

Outlet (Superheated steam)

p = 600\,kPa

T = 160\,^{\circ}C

h_{out} = 2758.9\,\frac{kJ}{kg}

If we know that \dot m = 50\,\frac{kJ}{kg}, h_{in} = 3024.2\,\frac{kJ}{kg}, h_{out} = 2758.9\,\frac{kJ}{kg} and v_{in} = 30\,\frac{m}{s}, then the flow speed at outlet is:

35765-25\cdot v_{out}^{2} = 0 (2)

v_{out} \approx 37.823\,\frac{m}{s}

The flow velocity at outlet is approximately 37.823 meters per second.

The mass flow is related to the inlet radius (r_{in}), in meters, by this expression:

\dot m = \frac{\pi \cdot v_{in}\cdot r_{in}^{2} }{\nu_{in}} (3)

If we know that \dot m = 50\,\frac{kJ}{kg}, v_{in} = 30\,\frac{m}{s} and \nu_{in} = 0.12551\,\frac{m^{3}}{kg}, then the inlet radius is:

r_{in} = \sqrt{\frac{\dot m\cdot \nu_{in}}{\pi\cdot v_{in}}}

r_{in}\approx 0.258\,m

The inlet radius of the nozzle is approximately 0.258 meters.  

7 0
2 years ago
Other questions:
  • To make 1000 containers of ice cream you need: 600 gallons of milk, 275 gallons of cream, and 120 gallons of flavor. Each ingred
    12·1 answer
  • for high-volume production runs, machining parts from solid material might not be the best choice of manufacturing operations be
    12·1 answer
  • The nameplate on a 70 kVA transformer shows a primary voltage of 480 volts and a secondary voltage of 115 volts. We wish to dete
    10·1 answer
  • La base de los tema relacionados a las ciencia de las ingeniería es?
    7·1 answer
  • Define the coefficient of determination and discuss the impact you would expect it to have on your engineering decision-making b
    15·1 answer
  • E xercise 17.1.2: For each of the transactions of Exercise 17.1.1, add the read- and write-actions to the computation and show t
    12·1 answer
  • 14. The maximum amount a homeowner should spend on housing is
    11·1 answer
  • El protozoos es del reino protista?
    14·2 answers
  • Cast iron has about how much carbon content?
    12·1 answer
  • Explain how you would solve for total resistance in a parallel circuit versus a series circuit. How would you apply and solve fo
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!