Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python 3 w/ PyCharm - Starter file: https://pastebin.com/rPcaHdgi Pokemon are fantastic creatures that people can catch and train. Pokemon are classified into different types such

Python 3 w/ PyCharm

-

Starter file: https://pastebin.com/rPcaHdgi

image text in transcribed

image text in transcribed

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 wil 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 continents where you can find pokemon 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. Individually.none of these questions are particularly difficult,but fyou make a mistake anywhere along the way, then the last part wont 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 adifferent input fle. Therefore, you must make sure your code is fully general: dont 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 pokedat a) that takes as parameter(s) a string indicating the name of a pokemon location data file This function should return a database(ie. a dictionary-of-dictionaries) that stores all of the Pokemon data n a format that we will describe further below. You can review section 1119 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 vysaur 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 (ie 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 Ge 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 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 wil 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 continents where you can find pokemon 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. Individually.none of these questions are particularly difficult,but fyou make a mistake anywhere along the way, then the last part wont 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 adifferent input fle. Therefore, you must make sure your code is fully general: dont 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 pokedat a) that takes as parameter(s) a string indicating the name of a pokemon location data file This function should return a database(ie. a dictionary-of-dictionaries) that stores all of the Pokemon data n a format that we will describe further below. You can review section 1119 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 vysaur 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 (ie 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 Ge 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Inductive Databases And Constraint Based Data Mining

Authors: Saso Dzeroski ,Bart Goethals ,Pance Panov

2010th Edition

1489982175, 978-1489982179

More Books

Students also viewed these Databases questions