1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Studentka2010 [4]
3 years ago
6

Design and implement a class Country that stores the name of the country, its population, its area, and the population density (

i.e., people per square kilometer (or mile). In other words, there are four major methods in this class (i.e., get country name, get area information, get population information, and get population density information). Then, write a test file that reads data.txt and prints the following three tasks by leveraging methods from the Country() class.  The country with the largest area. The country with the largest population.  The country with the largest population density You should turn in TWO Python files in this question. One is a Country class file and the other is the test program that leverages the methods from the Country()class and print the above three requests. You could leverage set() to store country information and do the operations.

Computers and Technology
1 answer:
melomori [17]3 years ago
4 0

Answer:

See explaination

Explanation:

Make use of Python programming language.

File: Country.py

class Country:

def __init__(self, n="", p=0, a=0):

""" Constructor """

self.name = n

self.population = p

self.area = a

self.pDensity = self.population / self.area

def getCountryName(self):

""" Getter method """

return self.name

def getPopulation(self):

""" Getter Method """

return self.population

def getArea(self):

""" Getter Method """

return self.area

def getPDensity(self):

""" Getter Method """

return self.pDensity

File: CountryInfo.py

from Country import *

# Opening file for reading

with open("d:\\Python\\data.txt", "r") as fp:

# List that hold countries

countryInfo = []

# Processing file line by line

for line in fp:

# Stripping spaces and new lines

line = line.strip()

# Splitting and creating object

cols = line.split('\t')

cols[1] = cols[1].replace(',', '')

cols[2] = cols[2].replace(',', '')

c = Country(cols[0], int(cols[1]), float(cols[2]))

countryInfo.append(c)

# Processing each countryInfo

largestPop = 0

largestArea = 0

largestPDensity = 0

# Iterating over list

for i in range(len(countryInfo)):

# Checking population

if countryInfo[i].getPopulation() > countryInfo[largestPop].getPopulation():

largestPop = i;

# Checking area

if countryInfo[i].getArea() > countryInfo[largestPop].getArea():

largestArea = i;

# Checking population density

if countryInfo[i].getPDensity() > countryInfo[largestPop].getPDensity():

largestPDensity = i;

print("\nLargest population: " + countryInfo[largestPop].getCountryName())

print("\nLargest area: " + countryInfo[largestArea].getCountryName())

print("\nLargest population density: " + countryInfo[largestPDensity].getCountryName() + "\n")

Please go to attachment for sample program run

You might be interested in
A.<br>Define a computer with its proper meaning.​
Rashid [163]

Answer:

Computer

Explanation:

a programmable electronic device designed to accept data, perform prescribed mathematical and logical operations at high speed, and display the results of these operations.

7 0
3 years ago
Read 2 more answers
The research department of Mark ‘2’ Limited in a recent stakeholder meeting argued that socially responsible businesses win the
Mama L [17]

The organization’s social responsibilities to its key stakeholders, the environment, and the community are:

  • The issue of Organizational governance.
  • The issue of Human rights.
  • The issue of Labor practices.
  • The issue of Environment.
  • The issue of Fair operating practices.
  • The issue of  Consumer issues.

<h3>What is an organization's social responsibilities to the environment and the community?</h3>

Social responsibility is known to be a term that is often used  in businesses, and it is often used in line with the maximizing of shareholder value.

Note that this is one that entails that firms should act in a manner that is said to often benefits society. Socially responsible companies should use policies that tend to boast or promote the well-being of society and that of the environment.

Therefore, The organization’s social responsibilities to its key stakeholders, the environment, and the community are:

  • The issue of Organizational governance.
  • The issue of Human rights.
  • The issue of Labor practices.
  • The issue of Environment.
  • The issue of Fair operating practices.
  • The issue of  Consumer issues.

Learn more about social responsibilities from

brainly.com/question/12951431

#SPJ1

7 0
2 years ago
Develetech has a security policy that mandates a basic security feature for mobile device access. What is this basic security fe
kirill [66]

Answer:A password or a PIN

Explanation: Develetech is a industry that has the a internet page and can also be used in the mobile devices. There is particular authorization that the organization provides to an individual user for accessing of the services to maintain the security .The security is maintained by providing the devices with an encrypted text that is known as the password. The user has to enter the pin or password to execute the service on device.

5 0
3 years ago
The number of colors available in a graphic is referred to as color what?
Drupady [299]
With 8<span> bits used to represent each color value, one pixel requires </span>24<span> bits. The number of colors available in a graphic is referred to as color depth. I hope you understand! :-)</span>
5 0
3 years ago
David was editing his audio recording in his audio editing software. He adjusted the vocal track of his audio toward
Dmitrij [34]

Answer:

b

Explanation:

balancing the sound

a                h    o

l                 e    u

a                      n

n                      d

c

i

n

g

6 0
2 years ago
Other questions:
  • The rmdir command (with no options) can only remove empty directories <br> a. True <br> b. False
    14·1 answer
  • The keyboard, mouse, trackpad, microphone, light pen, and voice recognition are examples of _____ devices.
    5·1 answer
  • Peter has recently bought a media player and a digital camera he wants to buy a memory card and then use devices which memory do
    11·2 answers
  • Jim has to send an email to his boss requesting medical leave. in which field will Jim type the purpose of his email?​
    8·2 answers
  • A project manager is responsible for (check all that apply)
    13·1 answer
  • What kind of app or technology would you like to create?  Why ? <br><br><br>​
    11·1 answer
  • Which of the following is equivalent to (p&gt;=q)? <br> i) P q iv) !p Where are genius people?:)
    6·1 answer
  • A photographer stores digital photographs on her computer. In this case the photographs are considered the data. Each photograph
    6·1 answer
  • 100 POINTS!!!!!!!
    15·2 answers
  • List at least 5 disadvantages caused by computer viruses?​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!