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
Agata [3.3K]
3 years ago
7

#Write a function called population_density. The function #should take one parameter, which will be a list of #dictionaries. Eac

h dictionary in the list will have three #key-value pairs: # # - name: the name of the country # - population: the population of that country # - area: the area of that country (in km^2) # #Your function should return the population density of all #the countries put together. You can calculate this by #summing all the populations, summing all the areas, and #dividing the total population by the total area. # #Note that the input to this function will look quite long; #don't let that scare you. That's just because dictionaries #take a lot of text to define. #Add your function here!
Computers and Technology
1 answer:
Radda [10]3 years ago
3 0

Answer:

def population_density(dictionary_list):

     """ this function calculates the population density of a list of countries"""

    total_population= 0

    total_area= 0

    for country in dictionary_list:

           total_population += country['population']

           total_area += country['area']

    population_density = total_population / total_area

    return population_density

Explanation:

In python, functions are defined by the "def" keyword and a dictionary is used to hold immutable data key and its value. The for loop is used to loop through the list of dictionaries and the values of the country data and extracted with bracket notation.

You might be interested in
private members of a class are accessible only from _____________ of the same class or from their friends
maxonik [38]

Answer: Within other member

Explanation:

 The private data member is also known as private function in the computer programming language. The private keyword is basically used to specify the access level and also provide the variable and the methods control to the programmers in the class.

In the class, the variables and the method are directly access by the other methods with the same class but not directly access by the derived class. Therefore, the private members of the class are easily access from the other member of the similar class and also from friends.    

8 0
3 years ago
Which of the following class definition defines a legal abstract class Group of answer choices public class Rectangle abstract {
valkas [14]
<h2>Question</h2>

Which of the following class definition defines a legal abstract class Group of answer choices

(a)

public class Rectangle abstract {

   public abstract double findArea ( );

   

}

(b)

public abstract class Rectangle {

   public abstract double findArea ( );

   

}

(c)

public class Rectangle {

   public abstract double findArea ( );

   

}

(d)

public class abstract Rectangle {

   public abstract double findArea ( );

   

}

<h2>Answer:</h2>

(b)

public abstract class Rectangle {

   public abstract double findArea ( );

}

<h2>Explanation:</h2>

When a class is declared with the abstract keyword, the class is called an abstract class. Abstract classes cannot be instantiated and may include one or more abstract methods. If a class contains an abstract method, then it (the class) must be declared abstract.

In Java, abstract classes are defined using the following format:

<em>[access_modifier]</em> abstract class <em>[name_of_class]</em>

[access_modifier] specifies the access modifier of the class which could be public, private, e.t.c

abstract is the keyword that specifies that the class is an abstract class.

class is a keyword used for defining classes

name_of_class specifies the name of the class.

The only option that fulfils this format is <em>option b</em> where;

(i) The access modifier is public

(ii) The name of the class is Rectangle

Option a is not correct because the <em>abstract</em> keyword is supposed to come before the <em>class</em> keyword.

Option c is not correct because the keyword <em>abstract</em> is missing. In other words, the class must be declared abstract since it contains abstract method findArea();

Option d is not correct because the <em>abstract</em> keyword is supposed to come before the <em>class</em> keyword.

7 0
2 years ago
What is a web client ​
Anna [14]

Explanation: It's something like siri. It's a machine or technology inside a phone or computer that gives you information to a question that you asked.

5 0
3 years ago
Read 2 more answers
Help me please, I'm attempting a test<br>​
dusya [7]
It’s A it’s a keyboard
8 0
2 years ago
Read 2 more answers
The best way to share criticism is to ______. a. write it in the break room b. talk it about with all your coworkers c. talk abo
ICE Princess25 [194]

Answer:

C.

Explanation:

6 0
3 years ago
Read 2 more answers
Other questions:
  • A _________ is the broadcast of various types of media over the web.
    10·2 answers
  • What file may contain data written to it in case of an unexpected error or program shut-down?
    5·1 answer
  • Which forensics tool would you use to reveal recent pages viewed via the internet explorer browser?
    10·1 answer
  • Write a program that gets a single character from the user. If the character is not a capital letter (between 'A' and 'Z'), then
    15·1 answer
  • Which piece of computer hardware was revised to run hypervisors natively?
    12·2 answers
  • What answer best explains why improper netiquette is considered dangerous? Individuals who violate user policies are often charg
    14·2 answers
  • Find the smallest value of n such that LCM of n is 15 is 45​
    5·1 answer
  • If you can photoshop please text me i need help for my digital media class 7862381441
    9·1 answer
  • In addition to assuming that n is a power of 2, we made, for the sake of simplicity, another, more subtle, assumption in setting
    5·1 answer
  • 15. Question
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!