In python,

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

In python,

Post by answerhappygod »

In python,
In Python 1
In Python 1 (27.19 KiB) Viewed 38 times
Create a dictionary that maps countries to their capitals. You may start with an empty dictionary. Ask the user to input the name of the country and its capital and add them to the dictionary. E.g.. capitals = {'Argentina Buenos Aires'. 'France":"Paris'. 'US': 'Washington D.C.'} Once the dictionary is created, print the countries, in alphabetical order, and the capitals. Here is a sample run: Enter a country and a capital com Enter a country and a capital comma separated (Q to quit): France.Paris Enter a country and a capital comma separated (Q to quit): United States.Washington D.C. Enter a country and a capital comma separated (Q to quit): Spain Madrid Enter a country and a capital comma separated (Q to quit): Q COUNTRY France Japan Spain United States omma separated (Q to quit): Japan, Tokyo CAPITAL Paris Tokyo Madrid Washington D.C. |
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply