ComeçarComece de graça

Meanwhile, in other categories...

We learned in the last exercise that there has been significantly more sharing of physics prizes since World War II: the ratio of the number of unshared-prize laureates in physics in or after 1945 to the number of shared-prize laureates is approximately 0.13. What is this ratio for prize categories other than physics, chemistry, and medicine?

Este exercício faz parte do curso

Introduction to MongoDB in Python

Ver curso

Instruções do exercício

  • Save an $elemMatch filter unshared to count laureates with unshared prizes in categories other than ("not in") ["physics", "chemistry", "medicine"] in or after 1945.
  • Save an $elemMatch filter shared to count laureates with shared (i.e., "share" is not "1") prizes in categories other than ["physics", "chemistry", "medicine"] in or after 1945.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# Save a filter for laureates with unshared prizes
unshared = {
    "prizes": {____: {
        ____: {____: ["physics", "chemistry", "medicine"]},
        "share": "1",
        "year": {____: "1945"},
    }}}

# Save a filter for laureates with shared prizes
shared = {
    "prizes": {____: {
        ____: {____: ["physics", "chemistry", "medicine"]},
        "share": {____: "1"},
        "year": {____: "1945"},
    }}}

ratio = db.laureates.count_documents(unshared) / db.laureates.count_documents(shared)
print(ratio)
Editar e executar o código