Write a program in python that uses a class named Nation to create a dictionary from...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Answer rating: 100% (QA)
Here is an example implementation of the program in Python import pickle ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Marina Company Work Sheet For the Year Ended December 31, 2012 Trial Balance Adjustments Income Statement Balance Sheet Accounts Cash Dr. Cr. Ref. Dr. Cr. Ref. Dr. Cr. Ref. Dr. Cr. S 12.400 Equity...
-
What functions are there in the mazeAsn4 module: print_maze(maze) Description: This function displays the maze. The accessible cells are labelled G i.e. green, the blocked cells are labelled R i.e....
-
Consider an input data of the form X= (Xo, X, X2,....., Xn-1) where each X is a byte. A suggested hash function is h(X) = Xo+ X + X+.....+ Xn-1 where + stands for bitwise modulo two addition. Explain...
-
Determine whether the given set of matrices under the specified operation, matrix addition or multiplication, is a group. Recall that a diagonal matrix is a square matrix whose only nonzero entries...
-
A thin beam of white light is directed at a flat sheet of silicate flint glass at an angle of 20.0? to the surface of the sheet. Due to dispersion in the glass, the beam is spread out as shown in a...
-
Set up an integral that represents the length of the part of the parametric curve shown in the graph. Then use a calculator (or computer) to find the length correct to four decimal places. x = t cos...
-
Assume that in a digital communication channel, the number of bits received in error can be modeled by a binomial random variable, and assume that the probability that a bit is received in error is...
-
Calculate the magnitude and direction of the net gravitational force on the moon due to the earth and the sun when the moon is in each of the positions shown in Fig. 12.32. (Note that the figure is...
-
Staples sells CDs ( $ 2 , 0 0 ) and box s of computer Paper ( $ 3 ) . If total sales Were $ 1 , 5 6 0 and customers bought 5 times as many CDs as boxes of compute paper how many obs were sold?,
-
On May 1, Janeka Clothing Exchange paid cash of $54,000 for computers that are expected to remain useful for three years. At the end of three years, the value of the computers is expected to be zero....
-
Detailed Design Describe a detailed flow between the components for a video viewing application like YouTube.
-
True/False and Explain: Hareth says that in the real-world, venture capital firms should use the CAPM to estimate the cost of capital for their portfolio companies, because the investors that provide...
-
7. As investor, should you be happy about Starbucks' decision to pay a dividend? Should Starbucks have initiated a dividend sooner? Look at Starbuck's free cash flow to equity holders
-
Property vs stock vs bond investment. Which one is better and low risk? Discuss.
-
(i) Create a User class that contains a single instance variable of String type to represent a user name, a constructor that takes a passed parameter to initialise the instance variable name, a...
-
ABC Inc. will be growing its business in the coming year. This will increase inventory by $10,400; increase in property, plant, and equipment of $30,900 ; an increase in accounts payable of $1,100...
-
What is the recommended IV fluid (NS or LR) bolus dose for a pt. who achieves ROSC but is hypotensive during the post-cardiac arrest period?
-
The Home Depot is the leading retailer in the home improvement industry and one of the 10largest retailers in the United States. The company included the following on its January 29, 2012, balance...
-
You can describe a simple list as follows: The simple list can hold zero or more items of some particular type. You can create an empty list. You can add items to the list. You can determine whether...
-
Is the following statement valid? If not, why not? If so, what does it do? int x = (1,024); What about the following? int y; y = 1,024;
-
Design a function calculate() that takes two type double values and a pointer to a function that takes two double arguments and returns a double. The calculate() function should also be type double,...
-
Give examples of policies that a country could implement to reduce its absorption.
-
In Section 6.2.3, we made the comment "Perception is reality." How does this play in the valuation of a tangible versus intangible asset? 6.2.3 Politics to explore Our roadmap for this chapter would...
-
We discussed risk aversion as being descriptive of investor behavior. Can Do you think of any real-world behavior that you might consider to be evidence of the existence of risk preferrers?
Study smarter with the SolutionInn App