Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please read the requirement carefully Overview Pokemon are fantastic creatures that people can catch and train. Pokemon are classified into different 'types such as grass,

image text in transcribedimage text in transcribed

Please read the requirement carefully

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

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

Oracle 10g SQL

Authors: Joan Casteel, Lannes Morris Murphy

1st Edition

141883629X, 9781418836290

More Books

Students also viewed these Databases questions

Question

5-23. For living, I require money.

Answered: 1 week ago