Python:MongoDB

From Progzoo
Jump to: navigation, search

The mongo collection progzoo contains the document world. Each element of world represents a country such as:

 {  
     _id:        "558b1fd3b0323f891aeb2010",
     area:       640679.0,
     capital:    "Paris",
     continent:  "Europe",
     flag:       "//upload.wikimedia.org/wikipedia/commons/c/c3/Flag_of_France.svg",
     gdp:        2611221000000.0,
     name:       "France",
     population: 65906000.0
     tld:        ".fr",
 }

Capital of France

The query given show the GDP of United Kingdom.

What is the capital of France?


[Font] [Default] [Show] [Resize] [History] [Profile]

Large Countries

The $lt operator is short for "less than". This query shows all countries with an area of less than 100 square kilometers

Show each country where the population is greater than 200 million (200000000).


[Font] [Default] [Show] [Resize] [History] [Profile]

Per Capita GDP

Show the per capita GDP for the countries of Europe. That is the gdp divide by the population.

You will need to use aggregation with $match, $project and $divide to complete this.


[Font] [Default] [Show] [Resize] [History] [Profile]