def create_dict_by_region(directory_path, number_of_regions): """ Given a directory of files with name of the form "regionN.txt" where goes from 1 to number_of_regions. Create two dictionaries: - dict1: a dictionary where the keys are the region number and the value is the name of that region. - dict2: a dictionary where the keys are the names of the regions and the value is a list of the states in that region. :param directory_path: the directory where these files are :param: number_of_regions: the number of region files we expect to find in the directory :return: tuple of the two dictionaries dict1, dict2 """ REGIONS FILES: REGION1 FILE: North PA NY REGION 2 FILE: Middle VA MD NC REGION 3 FILE: South GA AL REGION 4 File: West TX NM OK CA

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter14: Files And Streams
Section: Chapter Questions
Problem 1CP
icon
Related questions
Question

def create_dict_by_region(directory_path, number_of_regions):
"""
Given a directory of files with name of the form "regionN.txt" where goes from
1 to number_of_regions.
Create two dictionaries:
- dict1: a dictionary where the keys are the region number and the value is the name
of that region.
- dict2: a dictionary where the keys are the names of the regions and the value is
a list of the states in that region.

:param directory_path: the directory where these files are
:param: number_of_regions: the number of region files we expect to find in the directory
:return: tuple of the two dictionaries dict1, dict2
"""
REGIONS FILES:

REGION1 FILE:
North

PA

NY

REGION 2 FILE:

Middle VA MD NC

REGION 3 FILE:

South GA AL

REGION 4 File:

West TX NM OK CA

adef create_dict_by_region(directory_path, number of regions):
Given a directory of files with name of the form "regionN.txt" where goes from
1 to number_of_regions.
Create two dictionaries:
dict1: a dictionary where the keys are the region number and the value is the name
of that region.
- dict2:
a list of the states in that region.
a dictionary where the keys are the names of the regions and the value is
:param directory_path: the directory where these files are
:param: number_of_regions: the number of region files we expect to find in the directory
:return: tuple of the two dictionaries dict1, dict2
Transcribed Image Text:adef create_dict_by_region(directory_path, number of regions): Given a directory of files with name of the form "regionN.txt" where goes from 1 to number_of_regions. Create two dictionaries: dict1: a dictionary where the keys are the region number and the value is the name of that region. - dict2: a list of the states in that region. a dictionary where the keys are the names of the regions and the value is :param directory_path: the directory where these files are :param: number_of_regions: the number of region files we expect to find in the directory :return: tuple of the two dictionaries dict1, dict2
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Dictionary
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage