Question
I need help with this xml!
Write a CSS file that renders the that will render the following XML file <?xml version-1.0?> <?xml-stylesheet type-text/c
as shown in the following screenshot Note: You are not supposed to modify the XML content ← → à file:///HJCSC4356/Notes/Q1/Q1
0 0
Add a comment Improve this question Transcribed image text
Answer #1

class Nation:

    def __init__(self, country="", continent="", population=0.0, area=0):

        self._country = country

        self._continent = continent

        self._population = population

        self._area = area

    def setCountry(self, country):

        self._country = country

    def setContinent(self, continent):

        self._continent = continent

    def setPopulation(self, population):

        self._population = population

    def setArea(self, area):

        self._area = area

    def getCountry(self):

        return self._country

    def getContinent(self):

        return self._continent

    def getPopulation(self):

        return self._population

    def getArea(self):

        return self._area

    def popDensity(self):

        self._popDensity = (1000000 * self._population) / self._area

        return self._popDensity

with open('UN.txt','r') as f:

    out=f.read()

out=out.split('\n')

cntry_dict={}

for inp in out:

    inp_cpy=inp.split(',')

    cntry_dict[inp_cpy[0]]=Nation(inp_cpy[0],inp_cpy[1],inp_cpy[2],inp_cpy[3])

import pickle

with open('nationsDict.dat', 'wb') as handle:

    pickle.dump(cntry_dict, handle, protocol=pickle.HIGHEST_PROTOCOL)

with open('nationsDict.dat', 'rb') as handle:

    cntry_dict_copy = pickle.load(handle)

out=raw_input('Enter a Country:')

print("""

Continent: %s

Population: %s

Area: %s square miles""" % (cntry_dict_copy[out]._continent,cntry_dict_copy[out]._population,cntry_dict_copy[out]._area))

Add a comment
Know the answer?
Add Answer to:
I need help with this xml! Write a CSS file that renders the that will render...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT