Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello! Looking for assistance for my Python programming project. I am having issues with part (c) . I was able to have a nationsDict.dat created

Hello! Looking for assistance for my Python programming project. I am having issues with part (c) . I was able to have a nationsDict.dat created with part (b), and my code seems to work fine. If you could please help assist on the explanation and coding with a screenshot with all the indentations, I would be grateful.

1. United Nations: The file UN.txt gives data about the 193 members of the United Nations. Each line of the file contains four pieces of data about a country - name, continent, population (in millions), and land area (in square miles).

(a)I need help creating a class named Nation with four instance variables to hold the data for a country and a method named popDensity that calculates the population density of the country. I need help writing a program that uses the class to create a dictionary of 193 items, where each item of the dictionary has the form

name of country: Nation object for that country

Use the file UN.txt to create the dictionary, and save the dictionary in a pickled binary file named nationsDict.dat. Also, save the class Nation in a file named nation.py

(b) I need assistance to write a program that requests the name of a U.N. member country as input, and then displays information about the country as shown in Fig 7.20. Use the pickled binary file nationsDict.dat and the file nation.py created in part (a)

(c) I need assistance write a program that requests the name of a continent as input, and then displays the names (in descending order) of the the five most densely populated U.N. member countries in that continent. See Fig 7.21. I need to use the pickled binary file nationsDict.dat and the file nation.py created in part (a).

Here is the UN.txt

Sweden,Europe,9.7,173732 Switzerland,Europe,8.1,15940 Syrian Arab Republic,Asia,18.0,71479 Tajikistan,Asia,8.1,55251 Thailand,Asia,67.7,198115 The former Yugoslav Republic of Macedonia,Europe,2.1,205 Timor-Leste,Asia,1.2,5743 Togo,Africa,7.4,21925 Tonga,Australia/Oceania,.11,289 Trinidad and Tobago,North America,1.2,1978 Tunisia,Africa,10.9,63170 Turkey,Asia,81.6,302535 Turkmenistan,Asia,5.1,188456 Tuvalu,Australia/Oceania,.011,10 Uganda,Africa,35.9,91136 Ukraine,Europe,44.3,233090 United Arab Emirates,Asia,5.6,32278 United Kingdom,Europe,66.7,94526 United Republic of Tanzania,Africa,50.0,364898 United States,North America,318.9,3794066 Uruguay,South America,3.3,68037 Uzbekistan,Asia,28.9,172742 Vanuatu,Australia/Oceania,.27,4706 Venezuela,South America,28.9,353841 Vietnam,Asia,93.4,128527 Yemen,Asia,26.1,203849 Zambia,Africa,14.7,290587 Zimbabwe,Africa,13.8,150871

image text in transcribed

FIGURE 7.21 Outcome of Prog. Project 1(c)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

??; Question: Discuss the importance of planning to organizations

Answered: 1 week ago