Chapter 4 Lab 1: Logic Operators

To complete this exercise connect to your Atlas cluster using the in-browser IDE space at the end of this chapter.

How many zips in the sample_training.zips dataset are neither over-populated nor under-populated?

In this case, we consider population of more than 1,000,000 to be over- populated and less than 5,000 to be under-populated.

Copy/paste the exact numeric value of the result that you get into the response field.

1,if u want to get 5000-1,000,000 in range pop , just lt 1,000,000 and gt 5000

2if u want to exculde in the range ,just not lt 1,000,000 and gt 5000

which one result u want to get,or both?

if in the range it is 1****
if out of the range is ****7
or u just want to get more than 1,000,000 or less then 5000 two count number only

i dont know which one is the answer

Over 1,000,000 is over-populated.
Under 5,000 is under-populated.
You want the number that are neither over nor under.
So you want to count those that respect both conditions.
So you do not want to count those above 1,000,000 and you also do not want to count those under 5,000 at the same time.
So it looks like they want you to count the one between 5,000 and 1,000,000.

2 Likes

lte 1,000,000 and gte 5000 right?

but it show wrong

nevermind ,i passed all already

Hi @DRIOD_KIT,

Please take a look at your query that you have share in the screenshot. You aren’t using the right logic operator.

~ Shubham

Hi,

I’m facing a similar issue, please find the attached screenshot.

image

I tried both $lt & $gte and $gte and $gt and $lt.

Thanks.

Hi @Niveditha_Karunamurthy,

This means that the given range is an inclusive range. But in your query, you are excluding them by using $lt and $gt query.

~ Shubham

Hi @Shubham_Ranjan,

It works fine now - thanks. Apparently, I modified pop values in the DB, however the answer matches the exact numbers from Sample DB, I had to re-load in order to get this to work using my original syntax.

Same with IDE first test, my Cluster name was different (not Sandbox), so it didn’t accept my connection to the Cluster as valid one. I had to terminate and re-create to match Sandbox.

Thanks.

1 Like

hii ,
you can try the following query
db.zips.find({"$nor":[{“pop”:{"$gt": 1000000 }},{pop: { $lt: 5000 }}]}).count()
and result is 11193

Hi, this worked for me the other day, I had originally modified pop values directly in the DB.

Thanks.