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]
4 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]4 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
Technician A says that after replacing a power steering hose, the system should be flushed, refilled, and bled. Technician B say
dedylja [7]
The. Answer will be D
3 0
4 years ago
What tool should be used to loosen or tighten brake or fuel lines?
emmainna [20.7K]

The tool you would use are brake line wrenches.

4 0
3 years ago
What is a material safety data sheet? A. a categorized list of hazardous substances in an industry B. a document with safety inf
horsena [70]

Answer: A.

Explanation:

safety data sheet are documents that list information relating to occupational safety and health for the use of various substances and products.

3 0
3 years ago
A guitarist would use a tuner to change which element of music?
Deffense [45]

Answer: The pitch

Explanation:

4 0
3 years ago
Read 2 more answers
Water is the working fluid in an ideal Rankine cycle. The condenser pressure is 8 kPa, and saturated vapor enters the turbine at
sergeinik [125]

Explanation:

The obtained data from water properties tables are:

Point 1 (condenser exit) @ 8 KPa, saturated fluid

h_{f} = 173.358 \\h_{fg} = 2402.522

Point 2 (Pump exit) @ 18 MPa, saturated fluid & @ 4 MPa, saturated fluid

h_{2a} =  489.752\\h_{2b} =  313.2

Point 3 (Boiler exit) @ 18 MPa, saturated steam & @ 4 MPa, saturated steam

h_{3a} = 2701.26 \\s_{3a} = 7.1656\\h_{3b} = 2634.14\\s_{3b} = 7.6876

Point 4 (Turbine exit) @ 8 KPa, mixed fluid

x_{a} = 0.8608\\h_{4a} = 2241.448938\\x_{b} = 0.9291\\h_{4b} = 2405.54119

Calculate mass flow rates

Part a) @ 18 MPa

mass flow

\frac{100*10^6 }{w_{T} - w_{P}} = \frac{100*10^3 }{(h_{3a}  - h_{4a}) - (h_{2a}  - h_{f})}\\\\= \frac{100*10^ 3}{(2701.26  - 2241.448938 ) - (489.752  - 173.358)}\\\\= 697.2671076 \frac{kg}{s} = 2510161.587 \frac{kg}{hr}

Heat transfer rate through boiler

Q_{in}  = mass flow * (h_{3a} -  h_{2a})\\Q_{in} = (697.2671076)*(2701.26-489.752)\\\\Q_{in} = 1542011.787 W

Heat transfer rate through condenser

Q_{out}  = mass flow * (h_{4a} -  h_{f})\\Q_{out} = (697.2671076)*(2241.448938-173.358)\\\\Q_{out} = 1442011.787 W

Thermal Efficiency

n = \frac{W_{net}  }{Q_{in} } = \frac{100*10^3}{1542011.787}  \\\\n = 0.06485

Part b) @ 4 MPa

mass flow

\frac{100*10^6 }{w_{T} - w_{P}} = \frac{100*10^3 }{(h_{3b}  - h_{4b}) - (h_{2b}  - h_{f})}\\\\= \frac{100*10^ 3}{(2634.14  - 2405.54119 ) - (313.12  - 173.358)}\\\\= 1125 \frac{kg}{s} = 4052374.235 \frac{kg}{hr}

Heat transfer rate through boiler

Q_{in}  = mass flow * (h_{3b} -  h_{2b})\\Q_{in} = (1125.65951)*(2634.14-313.12)\\\\Q_{in} = 2612678.236 W

Heat transfer rate through condenser

Q_{out}  = mass flow * (h_{4b} -  h_{f})\\Q_{out} = (1125)*(2405.54119-173.358)\\\\Q_{out} = 2511206.089 W

Thermal Efficiency

n = \frac{W_{net}  }{Q_{in} } = \frac{100*10^3}{1542011.787}  \\\\n = 0.038275

6 0
3 years ago
Other questions:
  • Whats the pros about being in the army
    10·1 answer
  • If 1 uF capacitor is fully charged with 120 V across it, how much energy is stored in it? (a) 7.2 kJ (b) 7.2 mJ (c) 0.12 mJ (d)
    6·1 answer
  • 4.2 A vapor compression refrigeration machine uses 30kW of electric power to produce 50 tons of cooling. What is
    14·1 answer
  • Consider a system with two tasks, Task1 and Task2. Task1 has a period of 200 ms, and Task2 has a period of 300 ms. All tasks ini
    5·1 answer
  • The pressure in an automobile tire depends on thetemperature of the air in the tire. When the air temperature is25°C, the pressu
    11·1 answer
  • Koch traded Machine 1 for Machine 2 when the fair market value of both machines was $60,000. Koch originally purchased Machine 1
    10·1 answer
  • List fabrication methods of composite Materials.
    12·1 answer
  • MCQ : What are the main the constituents of acid rains?
    10·2 answers
  • Determine the design angle ϕ (0∘≤ϕ≤90 ∘) between struts AB and AC so that the 400 lb horizontal force has a component of 600 lb
    10·1 answer
  • A seamless pipe carries 2400m³ of steam per hour at a pressure of 1.4N/mm².The velocity of flow is 30m/s.assuming the tensile st
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!