The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 6 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
Hello, I am in an introductory Python class and need help finishing up my assignment. In class, we have learned how to use classes, objects, sets, dictionaries, loops, and other basic coding practices. I just need help creating the last few functions. below are the documents and .py files needed to understand the assignment. assignment4.py is were I am having trouble. Thanks
class CountryCatalogue:
   def __init__(self, filename):
       cDictionary = dict()
       catalogue = []
       country = []
       file = open(filename)
       content = file.readlines()
       for line in content:
           data = line.split(",")
           catalogue.append(data[0])
           cDictionary[data[0]] = data[1]
Â
Â
   def filterCountriesByContinent(self):
   def printCountryCatalogue(self):
   def findCountry(self):
Â
   def deleteCountry(self):
Â
   def addCountry(self):
       cName = input("Enter the country name: ")
       population = float(input("Enter the population: "))
       area = float(input("Enter the area: "))
       continent = input("Enter the continent: ")
Â
Â
   def setPopulationOfASelectedCountry(self):
Â
Â
Â
   def saveCountryCatalogue(self, filename):
Â
Â
Â
   def findCountryWithLargestPop(self):
       pop = 9999999
       for c in country:
           if c.Population > pop:
               pop = c.Population
       return pop
Â
   def findCountryWithSmallestArea(self):
       area = 0
       for c in country:
           if c.Area < area:
               area = c.Area
       return area
Â
Â
   def findMostPopulousContinent(self):
Â
Â
Â
   def filterCountriesByPopDensity(self):
       density = input("Enter the density: ")
       for c in country:
           if c.density == density:
               print(c)
class Country :
   def __init__(self, name, pop, area, continent) :
       self.Name=name
       self.Population =pop
       self.Area =area
       self.Continent =continent
       self.density =0
Â
Â
   def __repr__(self):
       return self.Name +" in "+self.Continent
Â
Â
   def setPopulation(self, pop):
       self.Population =pop
Â
   def getName(self) :
       return self.Name
Â
   def getArea(self) :
       return self.Area
Â
Â
   def getPopulation(self) :
       return self.Population
Â
   def getContinent(self):
       return self.Continent
Â
   def getPopDensity(self) :
       return self.density
Â
Â
   def save(self, outobject) :
       outobject =self.Name +"|"+self.Continent+"|"+self.Population+"|"+self.density
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly