For any and all questions relating to challenge 5.

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

Still have questions? Read all the FAQs here.

Is the hint reversed? The challenge is to find out which items cost over 10% more at the nearby (country?) store but the hintâs formula is to find out which items cost over 10% more at the city store.

22 Likes

The wording is a bit confusingâŚ which store is supposed to be the more expensive one? The city or the country? Is the âsmall townâ store considered âcountryâ??

12 Likes

Ha, I was wondering why neither my âdonât buyâ nor my âdo buyâ list matched any of the answers. Thatâs what I get for sleepily following the hint without question!

ETA: For comparison, the hint lists the formula

`C=(CityPriceâCountryPrice)/CountryPrice > 0.1`

The solution uses the formula

`(country_price - city_price)/city_price > 0.1`

(Also noticed that the Explanation/Solution seems to be incorrectly using variables from the previous challenge, such as wholesale_price_list.)

13 Likes

Yes. I checked over my solution several times and it does not match any of the multiple choice answers.

3 Likes

I assumed that the âtownâ mentioned in the story is a small town in the country, and the city would be farther to go. So only if the country shops are at least 10% more expensive would you add an item to the city shopping list or in other words avoid them in the country shop.

Also rather than use the hint equation which didnât give me lists that matched any answer, I stuck with my first pass one which was something like: if city < country*1.10.

9 Likes

I got the answer only by messing around and swapping my lists till they matched - isnât the city and country backwards? I admit that I assumed that she lived in the country and not the city, since the question just said âtownâ. Itâs kind of frustrating how ambiguous it is - I hope itâs intentional because if notâŚ

But anyways, can anyone help me understand why a condition like `country_price > 1.10 * city_price` doesnât end up with the same result? It gave me a different list but in my mind it should be the same.

Iâm trying to justify it with some math from the hint formula:
`(country_price - city_price) / city_price > 0.1`
`(country_price / city_price) - (city_price / city_price) > 0.1`
`(country_price / city_price) - (1) > 0.1`
`country_price / city_price > 0.1 + 1`
`country_price > 1.10 * city_price`

2 Likes

Only thing that confused me was i didnt catch that i was looking for the more expensive items and not the less expensive items. Funny how i fill in the gaps with how you would do things in real lifeâŚ Iâd be writing a list of things i wanna buyâŚ Not the things i that are too expensive. Anyways once i got over that i just edited my code to something that would present a clear answer. In a weird way its backwards because of thatâŚ Interested in optimization feedback though.

Spoiler

for (i) in range(len(cleaningsupplies_list)):
if country_price[i] <= 1.1*city_price[i]:
print(".")
else:
print(cleaningsupplies_list[i], âtoo expensiveâ)

2 Likes

What worked for me was to calculate which items cost 10% more in the country store than the city store. In terms of the wording of the problem, this would mean that the country store was the nearby store. The hint did not work for me, instead I used (country-city)/city > 0.1.

1 Like

AH. Iâm not great at math so just assumed that the hint given in the formula was what we were supposed to use. Then ran my code way too long before looking at the message board to find out why the code was working but none of my answers were in the multiple choice. Wonder if this was a typo or intentional, to give us the formula but not the exact equationâŚ

1 Like

the hint equation is wrong, was that intentional?

3 Likes

Video Solution: https://youtu.be/gGQx1kBuk7U

A good challenge that utilities concepts from previous days.

2 Likes

The wording is quite confusing. It would have been more helpful it was more explicit as to knowing if it is city or country pricing should be more expensive. Canât remember where Dot moved to as per previous challenges.

4 Likes

So, I wasnât sure which store was the closest store, and after making an assumption as to which prices would be more expensive, I generated the list of >10% more expensive items, but they didnât match the choices. I added lines to also calculate the list of >10% more expensive items from other store, and there was a match. Hooray.

I didnât internalize the initial narrative, but I gather from the country barn/cabin in the header image that Dot has moved to the country.

1 Like

Same here - but I didnât look at the hint till after Iâd noticed my first set of solutions didnât fit the answers, so assumed Iâd misunderstood and switched it.

My code was quite short and matched the correct answer. Using the ratio of country price to city price greater than 1.1 prints the item as too expensive.

``````print('Items that cost over 10% more than city items')
for i in range(19):
if country_price[i] / city_price[i] > 1.1:
print(cleaningsupplies_list[i])``````
5 Likes

My solution:

``````c=cleaningsupplies_list

print([c[i] for i in range(len(c)) if country_price[i]/city_price[i] > 1.1])``````
8 Likes

Another way to calculate the percentage:

``````print('Country Items that exceed 10% in cost\n'
'-------------------------------------- ')