Your function should open the file given as a parameter and read the data from it into a database. The keys for this database will be pokemon names, and the values will be records (i.e another dictionary) for the matching pokemon. First, the read_pokedata() function should create an empty dictionary to be the overall database. Then, for each pokemon from the input file, create one record (i.e. one dictionary) with the following fields: • The pokemon's name, as a string. • The pokemon's type, as a string. • The locations where the pokemon can be found, as a list of strings. This record should then be added to the database, using the pokemon's name as a key. Once all of the records have been added, the function should return the database dictionary.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Database Format
Your function should open the file given as a parameter and read the data from it into a database. The
keys for this database will be pokemon names, and the values will be records (i.e another dictionary) for
the matching pokemon.
First, the read_pokedata() function should create an empty dictionary to be the overall database.
Then, for each pokemon from the input file, create one record (i.e. one dictionary) with the following fields:
The pokemon's name, as a string.
• The pokemon's type, as a string.
The locations where the pokemon can be found, as a list of strings.
This record should then be added to the database, using the pokemon's name as a key.
Once all of the records have been added, the function should return the database dictionary.
1Yes, we are aware that in fact Pokemon can have more than one type.
Transcribed Image Text:Database Format Your function should open the file given as a parameter and read the data from it into a database. The keys for this database will be pokemon names, and the values will be records (i.e another dictionary) for the matching pokemon. First, the read_pokedata() function should create an empty dictionary to be the overall database. Then, for each pokemon from the input file, create one record (i.e. one dictionary) with the following fields: The pokemon's name, as a string. • The pokemon's type, as a string. The locations where the pokemon can be found, as a list of strings. This record should then be added to the database, using the pokemon's name as a key. Once all of the records have been added, the function should return the database dictionary. 1Yes, we are aware that in fact Pokemon can have more than one type.
Before starting this question, first, download the data file pokemonTypes.txt from the class Moodle. Make
sure to put it in the same folder as your a5.py python code.
Write a function called read_pokedata() that takes as parameter(s):
• a string indicating the name of a pokemon type data file
This function should return a database (i.e. a dictionary-of-dictionaries) that stores all of the Pokemon data
in a format that we will describe further below. You can review section 11.1.9 of the text for a refresher on
what databases look like using dictionaries.
Input File Format
The data file for this question looks like this:
bulbasaur,grass,South America
ivysaur,grass,Asia,Antarctica
Each line of the file contains all of the data for a single pokemon. The first item on the line is always the
pokemon's name; names are guaranteed to be unique. The second item is always the pokemon's type,
which in the example above, is the type grass. Following that are one or more continents where that
pokemon can be found. So Bulbasaur can only be found in South America, but Ivysaur can be found in
both Asia and Antarctica. Note that the continent names CAN contain spaces. All of the data items on a
each line are separated by commas.
Transcribed Image Text:Before starting this question, first, download the data file pokemonTypes.txt from the class Moodle. Make sure to put it in the same folder as your a5.py python code. Write a function called read_pokedata() that takes as parameter(s): • a string indicating the name of a pokemon type data file This function should return a database (i.e. a dictionary-of-dictionaries) that stores all of the Pokemon data in a format that we will describe further below. You can review section 11.1.9 of the text for a refresher on what databases look like using dictionaries. Input File Format The data file for this question looks like this: bulbasaur,grass,South America ivysaur,grass,Asia,Antarctica Each line of the file contains all of the data for a single pokemon. The first item on the line is always the pokemon's name; names are guaranteed to be unique. The second item is always the pokemon's type, which in the example above, is the type grass. Following that are one or more continents where that pokemon can be found. So Bulbasaur can only be found in South America, but Ivysaur can be found in both Asia and Antarctica. Note that the continent names CAN contain spaces. All of the data items on a each line are separated by commas.
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY