Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program in python that uses a class named Nation to create a dictionary from another file. The program should create a new
Write a program in python that uses a class named Nation to create a dictionary from another file. The program should create a new dictionary with the format: Name of a country: Nation object for that country The txt file looks similar to this: Afghanistan, Asia, 31.8,251772 Albania, Europe, 3.0,11100 Algeria, Africa, 38.3,919595 Andorra,Europe,.085,181 The program will pull the information from a .txt file and create a dictionary that will automatically save in a pickled binary file named nationsDict.dat NOTE: Would prefer an import/request, otherwise just hard coding it into the program will be sufficient. The program should contain the following: Create a class named Nation; with the following instance variables: o Country o Continent o Total population o Land area Create a method named popDensity that calculates the population density of the country uses a txt file to create a dictionary, and save that dictionary in a pickled binary file named nationsDict.dat
Step by Step Solution
★★★★★
3.44 Rating (141 Votes )
There are 3 Steps involved in it
Step: 1
Here is an example implementation of the program in Python import pickle ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started