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
what are three things that we would need and unlimiated amount of for all of us to obtain everything that we want?
Elanso [62]
Unlimited wants is an economic term that refers to humans’ insatiable appetite for things. We never get enough because there is always something else that we need or want. The term ‘unlimited wants’ is the side of human nature that wants an infinite number of things. However, the resources we have available to get these wants are limited.

There are two halves of scarcity that have plagued us ever since we first set foot on this Earth:

Limited resources.
Unlimited wants.
The Economics of Seinfeld says the following regarding the term:

“Unlimited wants essentially mean that people never get enough, that there is always something else that they would like to have.”

“When combined with limited resources, unlimited wants result in the fundamental problem of scarcity.”

Unlimited wants – limited resources

What we want and need has no limit, i.e., it is infinite. However, what we can afford is finite, i.e., it has a limit. This is a basic condition of human existence.

We are never completely satisfied with everything we consume. We consume a variety of goods and services, but they are never enough.

In other words, there is always something else that I, you, or anybody else would want or need.

The term applies to all socioeconomic groups. Low-income groups have limited resources, and their wants always exceed those resources. However, the same happens with middle-income and upper-income groups. They never feel they have enough.

The reason is a very simple one. Every income group’s resources are finite. However, unlimited want is a feature of every human.

Put simply; our wants and needs are infinite, but our wealth is not.

The economic problem – unlimited wants

‘The economic problem‘ is a term that economists use. It states that the finite resources of an economy are not enough to satisfy all our wants and needs. We also call it ‘the central economic problem‘ or ‘the basic economic problem.’

The main question we ask when considering ‘the economic problem’ is: “How do we satisfy unlimited wants with limited resources?”

As we cannot produce everything, we have to prioritize. We must decide what to produce, how to produce it, and how much to produce. We must also determine for whom to produce.

Human wants are constant and infinite, but the resources to satisfy them are finite. The resources cannot exceed the amount of human and natural resources available.

We produce things that we know people want, as long as we have the resources to make them. How strong or weak demand is determines how much we charge for those things. It also determines how much we produce (supply).

In other words, markets fores, i.e., the forces of supply and demand, in a free market economy, determine prices.

Wants vs. needs

Needs are things without which we cannot survive. Wants are things we desire. However, we can survive without those wants.

Food, water, and housing, for example, are needs. Clothing is also a need. Without food or water, we would die. We would probably die too without housing. In cold countries, we would not survive without clothing.

A nice car, smartphone, and vacation by the beach are wants. If I don’t have a nice car, I will still live. If I don’t go to Cancun for my winter break, I won’t die. However, I want these things.

Fundamental needs are key in the function of the economy. Wants, however, are the driving forces that stimulate demand for things, i.e., demand for goods and services.

We can say either ‘unlimited wants’ or ‘unlimited wants and needs.’

3 0
3 years ago
Q1) Determine the force in each member of the
Sever21 [200]

Answer:

  • CD = DE = DF = 0
  • BC = CE = 15 N tension
  • FA = 15 N compression
  • CF = 15√2 N compression
  • BF = 25 N tension
  • BG = 55/2 N tension
  • AB = (25√5)/2 N compression

Explanation:

The only vertical force that can be applied at joint D is that of link CD. Since joint D is stationary, there must be no vertical force. Hence the force in link CD must be zero, as must the force in link DE.

At joint E, the only horizontal force is that applied by link EF, so it, too, must be zero.

Then link CE has 15 N tension.

The downward force in CE must be balanced by an upward force in CF. Of that force, only 1/√2 of it will be vertical, so the force in CF is a compression of 15√2 N.

In order for the horizontal forces at C to be balanced the 15 N horizontal compression in CF must be balanced by a 15 N tension in BC.

At joint F, the 15 N horizontal compression in CF must be balanced by a 15 N compression in FA. CF contributes a downward force of 15 N at joint F. Together with the external load of 10 N, the total downward force at F is 25 N. Then the tension in BF must be 25 N to balance that.

At joint B, the 25 N downward vertical force in BF must be balanced by the vertical component of the compressive force in AB. That component is 2/√5 of the total force in AB, which must be a compression of 25√5/2 N.

The <em>horizontal</em> forces at joint B include the 15 N tension in BC and the 25/2 N compression in AB. These are balanced by a (25/2+15) N = 55/2 N tension in BG.

In summary, the link forces are ...

  • (25√5)/2 N compression in AB
  • 15 N tension in BC
  • 25 N tension in BF
  • 0 N in CD, DE, and EF
  • 15 N tension in CE
  • 15√2 compression in CF
  • 15 N compression in FA

_____

Note that the forces at the pins of G and A are in accordance with those that give a net torque about those point of 0, serving as a check on the above calculations.

8 0
3 years ago
In details and step-by-step, show how you apply the Bubble Sort algorithm on the following list of values. Your answer should sh
astraxan [27]

( 12 17 18 19 25 )

<u>Explanation:</u>

<u>First Pass:</u>

( 19 18 25 17 12 ) –> ( 18 19 25 17 12 ), Here, algorithm compares the first two elements, and swaps since 19 > 18.

( 18 19 25 17 12 ) –> ( 18 19 25 17 12 ), Now, since these elements are already in order (25 > 19), algorithm does not swap them.

( 18 19 25 17 12 ) –> ( 18 19 17 25 12 ), Swap since 25 > 17

( 18 19 17 25 12 ) –> ( 18 19 17 12 25 ), Swap since 25 > 12

<u>Second Pass:</u>

( 18 19 17 12 25 ) –> ( 18 19 17 12 25 )

( 18 19 17 12 25 ) –> ( 18 17 19 12 25 ), Swap since 19 > 17

( 18 17 19 12 25 ) –> ( 18 17 12 19 25 ), Swap since 19 > 12

( 18 17 12 19 25 ) –> ( 18 17 12 19 25 )

<u>Third Pass:</u>

( 18 17 12 19 25 ) –> ( 17 18 12 19 25 ), Swap since 18 > 17

( 17 18 12 19 25 ) –> ( 17 12 18 19 25 ), Swap since 18 > 12

( 17 12 18 19 25 ) –> ( 17 12 18 19 25 )

( 17 12 18 19 25 ) –> ( 17 12 18 19 25 )

<u>Fourth Pass:</u>

( 17 12 18 19 25 ) –> ( 12 17 18 19 25 ), Swap since 17 > 12

( 12 17 18 19 25 ) –> ( 12 17 18 19 25 ), Swap since 18 > 12

( 12 17 18 19 25 ) –> ( 12 17 18 19 25 )

( 12 17 18 19 25 ) –> ( 12 17 18 19 25 )

Now, the array is already sorted, but our algorithm does not know if it is completed. The algorithm needs one whole pass without any swap to know it is sorted.

<u>Fifth Pass:</u>

( 12 17 18 19 25 ) –> ( 12 17 18 19 25 )

( 12 17 18 19 25 ) –> ( 12 17 18 19 25 )

( 12 17 18 19 25 ) –> ( 12 17 18 19 25 )

( 12 17 18 19 25 ) –> ( 12 17 18 19 25 )

6 0
3 years ago
An organization sets its standards for quality according to the best product it can produce.
Marianna [84]
I believe it’s True, but please correct me if I’m wrong!
6 0
3 years ago
Read 2 more answers
A large class with 1,000 students took a quiz consisting of ten questions. To get an A, students needed to get 9 or 10 questions
VMariaS [17]

Answer:

a. 0.11

b. 110 students

c. 50 students

d. 0.46

e. 460 students

f. 540 students

g. 0.96

Explanation:

(See attachment below)

a. Probability that a student got an A

To get an A, the student needs to get 9 or 10 questions right.

That means we want P(X≥9);

P(X>9) = P(9)+P(10)

= 0.06+0.05=0.11

b. How many students got an A on the quiz

Total students = 1000

Probability of getting A = 0.11 ---- Calculated from (a)

Number of students = 0.11 * 1000

Number of students = 110 students

So,the number of students that got A is 110

c. How many students did not miss a single question

For a student not to miss a single question, then that student scores a total of 10 out of possible 10

P(10) = 0.05

Total Students = 1000

Number of Students = 0.05 * 1000

Number of Students = 50 students

We see that 5

d. Probability that a student pass the quiz

To pass, a student needed to get at least 6 questions right.

So we want P(X>=6);

P(X>=) =P(6)+P(7)+P(8)+P(9)+P(10)

=0.08+0.12+0.15+0.06+0.05=0.46

So, the probability of a student passing the quiz is 0.46

e. Number of students that pass the quiz

Total students = 1000

Probability of passing the quiz = 0.46 ----- Calculated from (d)

Number of students = 0.46 * 1000

Number of students = 460 students

So,the number of students that passed the test is 460

f. Number of students that failed the quiz

Total students = 1000

Total students that passed = 460 ----- Calculated from (e)

Number of students that failed = 1000 - 460

Number of students that failed = 540

So,the number of students that failed is 540

g. Probability that a student got at least one question right

This means that we want to solve for P(X>=1)

Using the complement rule,

P(X>=1) = 1 - P(X<1)

P(X>=1) = 1 - P(X=0)

P(X>=1) = 1 - 0.04

P(X>=1) = 0.96

7 0
3 years ago
Other questions:
  • Bananas are to be cooled from 28°C to 12°C at a rate of 1140 kg/h by a refrigerator that operates on a vapor-compression refrige
    6·1 answer
  • Let m be an integer in the set {0,1,2,3,4,5,6,7,8, 9}, and consider the following problem: determine m by asking 3-way questions
    12·1 answer
  • Write a matrix, that is a lower triangular matrix.
    15·1 answer
  • 1. Asphyxiation is a hazard posed by Compressed Natural Gas (CNG) vehicles and can be detected when you notice
    7·1 answer
  • How to design a solar panel<br>​
    7·1 answer
  • What is clearance? What is backlash? What is interference? Explain briefly.
    6·1 answer
  • A driver is traveling at a speed of 72 km/h in car A when he looks down to text a friend that he is running late. Just before he
    15·1 answer
  • For Figure Below, if the elevation of the benchmark A is 25.00 m above MSL:
    14·1 answer
  • Question #4
    15·1 answer
  • 2. What is the Function of the Camshaft in an Internal Combustion Engine?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!