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
Determine the combined moment about O due to the weight of the mailbox and the cross member AB. The mailbox weighs 3.2 lb and th
koban [17]

Answer:

Attached is the complete question but the weight of the mailbox and cross bar differs from the given values which are : weight of mail box = 3.2 Ib, weight of the uniform cross member = 10.3 Ib

Answer : moment of inertia = 186.7 Ib - in

Explanation:

Given data

weight of the mailbox = 3.2 Ib

weight of the uniform cross member = 10.3 Ib

The origin is of mailbox and cross member is 0

The perpendicular distance from Y axis of centroid of the mailbox

= 4 + (25/2) = 16.5"

The centroid of the bar =( ( 1 + 25 + 4 + 4 ) / 2 ) - 4  = 13"

therefore The moment of Inertia( Mo) = (3.2 * 16.5) + ( 10.3 * 13)

                                     = 52.8 + 133.9 = 186.7 Ib-in

8 0
3 years ago
Which option distinguishes the members of a software deployment process team most likely involved in the following scenario?
Alchen [17]

Answer:

A local bank, with several branches in three cities, requests changes to its mortgage calculation software.

5 0
3 years ago
If welding is being done in the vertical position, the torch should have a travel angle of?
siniylev [52]

Answer:

Between 35°– 45°

Explanation:

In the vertical position, Point the flame in the direction of travel. Keep the flame tip at the correct height above the base metal. An angle of 35°–45° should be maintained between the torch tip and the base metal. This angle may be varied up or down to heat or cool the weld pool if it is too narrow or too wide

4 0
2 years ago
How buy airpods in my phone​
Levart [38]

U mean how to connect them to your phone?

4 0
2 years ago
Read 2 more answers
What is the value of the work interaction in this process?
Cloud [144]

Answer:

The answer is "-121\  \frac{KJ}{Kg}".

Explanation:

Please find the correct question in the attachment file.

using formula:

\to W=-P_1V_1+P_2V_2 \\\\When \\\\\to W= \frac{P_1V_1-P_2V_2}{n-1}\ \   or \ \  \frac{RT_1 -RT_2}{n-1}\\\\

W =\frac{R(T_1 -T_2)}{n-1}\\\\

    =\frac{0.287(25 -237)}{1.5-1}\\\\=\frac{0.287(-212)}{0.5}\\\\=\frac{-60.844}{0.5}\\\\=-121.688 \frac{KJ}{Kg}\\\\=-121 \frac{KJ}{Kg}\\\\

7 0
3 years ago
Other questions:
  • Consider the series solution, Equation 5.42, for the plane wall with convection. Calculate midplane (x* = 0) and surface (x* = 1
    5·1 answer
  • A thin‐walled tube with a diameter of 12 mm and length of 25 m is used to carry exhaust gas from a smoke stack to the laboratory
    10·1 answer
  • When circuit switching is used, what is the maximum number of circuit-switched users that can be supported? Explain your answer
    6·1 answer
  • The Fibonacci sequence 1, 1, 2, 3, 5, 8, 13, 21…… starts with two 1s, and each term afterward is the sum of its two predecessors
    8·2 answers
  • g In the above water treatment facility, chemical concentration (mg/gal) within the tank can be considered uniform. The initial
    8·1 answer
  • Water flovs in a pipe of diameter 150 mm. The velocity of the water is measured at a certain spot which reflects the average flo
    13·1 answer
  • (a) Consider a germanium semiconductor at T 300 K. Calculate the thermal equilibrium electron and hole concentrations for (i) Nd
    7·1 answer
  • W<br>n só<br>i<br>Eo<br>E<br>find the transfer function​
    9·1 answer
  • The branding, packaging, and labeling of your product should accomplish all of the following except
    12·1 answer
  • Which of the following is critical when performing maintenance?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!