Challenge 2 Megathread

For any and all questions relating to challenge 2. :point_down:

For a tutorial on how to use Jupyter Notebook, we put together this video:

Still have questions? Read all the FAQs here.

2 Likes

Anyone else feel like the wording is also confusing on this question? The grocery_list variable is essentially unnecessary, and the question had me originally thinking that the percentage needed to be calculated on each individual list item, not a sum of both lists total like the hint said.

It doesn’t feel like it’s teaching or testing list manipulation or arithmetic functions very well. :frowning: Hoping the questions become more solid as the challenges continue.

49 Likes

Like the last question, the solution for this question does not actually solve the question! The correct answer should be 25.82% since the question specifically asks to give the answer “as a percentage of country prices”, yet the solution answer is calculated by determining the difference as a proportion of country prices. The “Percentage Difference Equation” given in the hint is actually the relative change equation according to Wikipedia, which we need to multiply by 100 to get a percentage.

21 Likes

For anyone looking for a solution

city=(sum(city_price))
country=(sum(country_price))
difference=(city-country)/country
print(difference)

it’s not pretty, but it works

17 Likes

I agree that answers should be in percentage form to match the question, but at least they’re all in the same format (pre multiplication-by-100).

9 Likes

Hoping to see things ramp up pretty soon here or I’m going to lose interest

7 Likes

Word of advice since things are getting confusing as we go along: always check the hints and if still cant figure it out come to the discussion.

12 Likes

so first I create the variable c to make the operation
c=(sum(city_price)- sum(country_price))/sum(country_price)
and then show the result saved in the c variable
print©

I almost lose my mind with these exercise until I found first you need to shift+enter the first box with the definition of list -_-

9 Likes

I do not think it’s required to create additional variables, just use what was given:
print(((sum(city_price) - (sum(country_price)))) / sum(country_price))

10 Likes

You’re magic, sometimes I just need to do it and this helped.

1 Like

Nice and clean! I appreciate what you did there.

Good advice! Always check the hints (tab at the bottom of each page), and when in doubt, come to the forum to see if any other users have asked/answered similar questions.

1 Like

Day 2 Video Solution: https://youtu.be/s1axRPzrnWs

8 Likes

I’ve learned to take a look at the hints. It felt like cheating at first, wanting to complete the question without the added help, but more often then not, the information there is necessary to understand and solve the question.

9 Likes

Some of the questions, especially the early ones can be easy, but some of them can also be quite difficult. I get a lot of value out of building good habits - coding every day for the 21 days and I also have fun doing it too, hopefully some of this can apply to you too.

3 Likes

Hi! Does anyone know how much time it takes for the points earned by each member of the team to be transferred into the team’s points? We are missing a few points here :sweat:

Here’s the simplified answer:

difference = ((sum(city_price) - sum(country_price)) / sum(country_price))
print(difference)

// 0.2581943645773432 (0.2582)

5 Likes

is there any value in calling the formula “difference” and then “printing” it after? I got the same output with just:

(sum(city_price)-sum(country_price))/(sum(country_price))

serious question - just trying to learn! :slight_smile: