50.2k views
5 votes
Create a dictionary containing three major rivers and the country each river runs through.

a. For example: ‘mississippi’: ‘United States’
b. Use a loop to print a sentence about each river. Perhaps: "The {key} runs through the {value} etc.
c. Use a loop to print each river in the dictionary.
d. Use a loop to print each key in the dictionary.

User Mikka
by
7.0k points

1 Answer

2 votes

Final answer:

A dictionary containing the Nile River (Egypt), Amazon River (Brazil), and Mississippi River (United States) is created. Sentences are printed for each river detailing the country it runs through. Additionally, loops are used to print just the rivers and their corresponding countries.

Step-by-step explanation:

Creating a Dictionary of Major Rivers

To demonstrate an understanding of geography and programming, let's create a dictionary of three major rivers and their respective countries:

  • Nile River: Egypt
  • Amazon River: Brazil
  • Mississippi River: United States

Using this dictionary, we can loop through to print statements about each river:

  • The Nile River runs through Egypt.
  • The Amazon River runs through Brazil.
  • The Mississippi River runs through the United States.

Next, we'll loop through the dictionary to print each river:

  • Nile River
  • Amazon River
  • Mississippi River

Last, we'll loop through to print only the countries (the keys of the dictionary):

  • Egypt
  • Brazil
  • United States
User Ivanleoncz
by
6.7k points