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
evablogger [386]
3 years ago
7

Create a class CitiesAndCountries with at least three methods: class CitiesAndCountries: def add_country(self, country_name): ""

" :param country_name: name of new country :return: True if added, False if duplicate """ def add_city(self, country_name, city_name): """ :param country_name: must be a country in the already defined countries :param city_name: name of new city. :return: True if added, False if not added """ def find_city(self, city_name): """ :param city_name: get all cities with that name, in all different countries :return: list of countries which have a city with that name, empty list if none """
Computers and Technology
1 answer:
sveticcg [70]3 years ago
6 0

Answer:

Check the explanation

Explanation:

class CitiesAndCountries:

   """

   This is the class which maintains a dictionary of the Countries with the cites in them.

   """

   def __init__(self):

       """

       Constructor for the class CitiesAndCountries.

       It defines a dictionary to store the names of the countries and a list of the cities which are in them

       Example of the the following dictionary when it is populated:

       citiesandcountries = {"india":["bhopal", "mumbai", "nagpur"], "usa":["new york", "seatlle"]

       Keeping the names in lowercase helps in search

       """

       self.citiesandcountries = {}  # This is the dictionary which stores the information

   def add_country(self, country_name):

       """

       The add_country function to add countries to our list.

       :param country_name: Name of the country to add to the dictionary

       :return: True if added to the dictionary, False if it is already present in the dictionary

       """

       if country_name.lower() not in self.citiesandcountries.keys():

           self.citiesandcountries[country_name.lower()] = [] # Storing the country name in lower case helps in

           # searching

           return True

       else:  # You could omit the else statement and directly return False, but it adds to readability.

           return False

   def add_city(self, country_name, city_name):

       """

       This function adds the cities names to the dictionary corresponding to their countries.

       :param country_name: Country to which the city belongs

       :param city_name:  Name of the city to be added

       :return: True if the country is present in the dictionary and the city is added to the list, else False

       """

       if country_name.lower() in self.citiesandcountries.keys():

           self.citiesandcountries[country_name.lower()].append(city_name.lower())

           return True

       else:

           return False

   def find_city(self, city_name):

       """

       This function is used to retrive a list of countries where the city with the given name is present

       :param city_name: Name of the city.

       :return: A list of all the countries where the city if present.

       """

       countries_with_city = []

       for country in self.citiesandcountries.keys():

           if city_name.lower() in self.citiesandcountries[country]:

               countries_with_city.append(country.title())

       return countries_with_city

You might be interested in
Assume that you have an array of integers named arr. Which of these code segments print the same results?
tresset_1 [31]

Answer:

II and III only

Explanation:

In Code segment II, the output of the array will be started form arr[0] and ends at the arr[length]. Because loop starts from 0 and ends at length of array. This will print the full array data.

In code segment III, the output will be all values of array as loop starts form first index and ends at last index.

On the other hand I code segment prints all array values except last value of the array. As the loop shows that, it will terminate at second last value of the array.

4 0
3 years ago
Table Setting in any occasion can add to the beauty and significance of the event. It may
Rudiy27

Answer:

HMMMM IM THINKING HMMMMM

Explanation:

7 0
3 years ago
how risk can impact each of the seven domains of a typical IT infrastructure: User, Workstation, Local Area Network (LAN), Local
juin [17]

Answer and Explanation:

User Domain:

Risk

  • User can destroy the data and delete all User can find checked and use a password to delete all the work User can insert the USB flash and Infected CD.

Work Station Domain:

  • The workstation domain has some software vulnerability that connects remotely and steals data.
  • A workstation can fail because of lost data.

LAN domain

  • A worm can spread and infect the computer.
  • LAN have some known software vulnerability.
  • An unauthorized access of the organization workstation in

LAN WAN domain

  • LAN WAN domain that consists of internet and semi-private lines Service providers have major network problems.
  • Server can receive the DOS File Transfer protocol can allow uploaded illegal software.

LAN/WAN Domain

  • The boundary between the trusted and untrusted zones.
  • Hacker can penetrate the IT infrastructure and gain access.
  • Week ingress and egress filtering performance.
  • A firewall with the ports open can allow access to the internet.

System Storage Domain:

  • A fire can destroy the data DOC can cripple the organization's email.
  • A database server can be attacked by the injection of SQL and corrupting data.

Remote Access Domain

  • Communication circuit outage the connections
  • Remote communication from the office can be unsecured VPN tunneling between the remote computer and router
5 0
3 years ago
Some smartphones use ______ text, where you press one key on the keyboard or keypad for each letter in a word, and software on t
Oksanka [162]

Answer:

The answer is "predictive".

Explanation:

The statement lacks some details, which can be answered by the choice of the question:

A. Presumptive .

B. suggestive .

C. interpretive.

D. predictive.

Predictive text is considered to be auto-correct text as well. It is an input technique, which allows people to type words onto a smartphone throughout the text field. It's focused on both the significance of the words and letters in the message, and certain choices were wrong, which can be defined as follows:

  • Option B and Option D both were wrong because it provides the synonyms of the words.
  • In option C It is wrong because it is a text version.

5 0
4 years ago
Whos really watching this guys bruh​
Ivahew [28]

Answer:

Me no

Explanation:

4 0
3 years ago
Read 2 more answers
Other questions:
  • in the breezy python gui module, what class provides the basic functionality for any window, such as the command buttons in the
    10·1 answer
  • Melissa is visiting a Web page that her co-workers frequently update throughout the day. If she wants o make sure she has the mo
    11·1 answer
  • _ is a model of computing in which computer processing, storage, software, and other services are provided as a shared pool of v
    10·1 answer
  • A computer company has $3840000 in research and development costs. Before accounting for these costs, the net income of the comp
    5·1 answer
  • What is logical memory?
    15·1 answer
  • Where can you access the property sheet
    8·1 answer
  • Angle parking spaces are generally entered at an angle about __________ from the curb.
    8·2 answers
  • Which tab of the ribbon should you go to for removing gridlines on a worksheet?​
    14·1 answer
  • :|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|:|
    5·2 answers
  • Ok it is important aspects which is perfect
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!