Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Overview Pokemon are fantastic creatures that people can catch and train. Pokemon are classified into different 'types such as grass, fire or electric. To catch
Overview Pokemon are fantastic creatures that people can catch and train. Pokemon are classified into different 'types such as grass, fire or electric. To catch different types of pokemon, you might have to travel all over the world! For this assignment, you will build a program that will help organize information about where to go to catch the different pokemon. This assignment is divided into 5 different questions', but in the end, your work from all of the questions will be combined to complete the overall program. The first four questions will each ask you to define a function that will perform a specific task. Make sure that the inputs (parameters) and outputs (return values) of your functions match the problem description exactly, or else the whole thing won't fit together properly! The following is a brief overview of how the questions for this assignment will fit together: Question 1 Read data about the pokemon from a text file and organize it as a database. You must fully complete this question before moving on. All of the other questions will depend on the database that you create here. Question 2: Build a list of all the unique co Question 3: Build a list of all the pokemon that can be found on a particular continent. Question 4: Count how many of each pokemon type occur within a given list of pokemon names. Question 5: For each continent, display the pokemon type counts. ntinents where you can find pokemon. Individually, none of these questions are particularly difficult, but if you make a mistake anywhere along the way, then the last part won't work. Make sure to perform simple testing, such as printing out lists or dictionaries. as you go to make sure that everything looks right. One last note of caution: we have given you an input file for this assignment, but be aware that we might test your program on a different input file. Therefore, you must make sure your code is fully general; don't count on knowing exactly how many pokemon there are, or on knowing exactly what the names of the pokemon types or locations might be Question 1 (6 points) Purpose: To practice the concept of dictionary as a database Degree of Difficulty: Moderate Before starting this question, first, download the data file pokemonLocations.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 location 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.19 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 grass1 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. 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. rattata,normal,South America, Europe, Antarctica raticate, normal,0ceania spearow,flying,South America,North America,Antarctica, Europe fearow, flying,Asia, Antarctica ekans, poison, Europe,Oceania,North America,Asia arbok, poison,South America pikachu,electric,North America,Oceania,Africa raichu,electric,North America sandshrew, ground,Asia,North America, South America sandslash, ground,Asia,South America, North America nidoranfemale, poison,Asia nidorina,poison,Africa, Europe,South America,Antarctica nidoqueen,poison,Africa,South America nidoranmale,poison,Asia,Africa,South America,North America nidorino,poison,Antarctica nidoking,poison,Africa, South America, Antarctica,Oceania clefairy,fairy,Asia clefable,fairy,Europe, North America vulpix, fire,North America,Antarctica,Oceania ninetales,fire, North America, Asia jigglypuff, fairy,Asia,Oceania, Europe,Africa wigglytuff,fairy,North America,Asia zubat,flying,Africa, Europe,Oceania,Asia golbat, flying,South America,Antarctica oddish, grass, Europe,Asia,North America gloom,grass,Oceania, Europe,Antarctica, North America vileplume, grass,Oceania,Antarctica paras,bug,Oceania,Antarctica,South America, Europe parasect,bug,Africa,South America,North America Overview Pokemon are fantastic creatures that people can catch and train. Pokemon are classified into different 'types such as grass, fire or electric. To catch different types of pokemon, you might have to travel all over the world! For this assignment, you will build a program that will help organize information about where to go to catch the different pokemon. This assignment is divided into 5 different questions', but in the end, your work from all of the questions will be combined to complete the overall program. The first four questions will each ask you to define a function that will perform a specific task. Make sure that the inputs (parameters) and outputs (return values) of your functions match the problem description exactly, or else the whole thing won't fit together properly! The following is a brief overview of how the questions for this assignment will fit together: Question 1 Read data about the pokemon from a text file and organize it as a database. You must fully complete this question before moving on. All of the other questions will depend on the database that you create here. Question 2: Build a list of all the unique co Question 3: Build a list of all the pokemon that can be found on a particular continent. Question 4: Count how many of each pokemon type occur within a given list of pokemon names. Question 5: For each continent, display the pokemon type counts. ntinents where you can find pokemon. Individually, none of these questions are particularly difficult, but if you make a mistake anywhere along the way, then the last part won't work. Make sure to perform simple testing, such as printing out lists or dictionaries. as you go to make sure that everything looks right. One last note of caution: we have given you an input file for this assignment, but be aware that we might test your program on a different input file. Therefore, you must make sure your code is fully general; don't count on knowing exactly how many pokemon there are, or on knowing exactly what the names of the pokemon types or locations might be Question 1 (6 points) Purpose: To practice the concept of dictionary as a database Degree of Difficulty: Moderate Before starting this question, first, download the data file pokemonLocations.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 location 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.19 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 grass1 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. 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. rattata,normal,South America, Europe, Antarctica raticate, normal,0ceania spearow,flying,South America,North America,Antarctica, Europe fearow, flying,Asia, Antarctica ekans, poison, Europe,Oceania,North America,Asia arbok, poison,South America pikachu,electric,North America,Oceania,Africa raichu,electric,North America sandshrew, ground,Asia,North America, South America sandslash, ground,Asia,South America, North America nidoranfemale, poison,Asia nidorina,poison,Africa, Europe,South America,Antarctica nidoqueen,poison,Africa,South America nidoranmale,poison,Asia,Africa,South America,North America nidorino,poison,Antarctica nidoking,poison,Africa, South America, Antarctica,Oceania clefairy,fairy,Asia clefable,fairy,Europe, North America vulpix, fire,North America,Antarctica,Oceania ninetales,fire, North America, Asia jigglypuff, fairy,Asia,Oceania, Europe,Africa wigglytuff,fairy,North America,Asia zubat,flying,Africa, Europe,Oceania,Asia golbat, flying,South America,Antarctica oddish, grass, Europe,Asia,North America gloom,grass,Oceania, Europe,Antarctica, North America vileplume, grass,Oceania,Antarctica paras,bug,Oceania,Antarctica,South America, Europe parasect,bug,Africa,South America,North America
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started