Program 4: Pokédex

User Generated

lnzv_0502

Programming

Description

ّi will upload 4 files. one has the instructions and the second has the code that needs to be modified. the third has txt file(pokedex) that needs to be used. and the forth is an output example (transcript)

Attachment preview

Learning Outcomes
To solve this problem, you need to understand the following Python concepts: object-oriented programming and lists.

Background Information
The file pokedex.txt contains partial information about 31 Pokémon that mostly come from this Pokédex.

Assignment
Using pokedex.py as a starting point, supply the missing functions such that interaction with a user could produce this transcript.

Unformatted Attachment Preview

3/10/19, 2)52 PM 1,bulbasaur,318,grass,poison 2,ivysaur,405,grass,poison 3,venusaur,525,grass,poison 4,charmander,309,fire 5,charmeleon,405,fire 6,charizard,534,fire,flying 7,squirtle,314,water 8,wartortle,405,water 9,blastoise,530,water 10,caterpie,195,bug 11,metapod,205,bug 12,butterfree,395,bug,flying 13,weedle,195,bug,poison 14,kakuna,205,bug,poison 15,beedrill,395,bug,poison 16,pidgey,251,normal,flying 17,pidgeotto,349,normal,flying 18,pidgeot,479,normal,flying 19,rattata,253,normal 20,raticate,413,normal 21,spearow,262,normal,flying 22,fearow,442,normal,flying 23,ekans,288,poison 24,arbok,448,poison 25,pikachu,320,electric 26,raichu,485,electric,psychic 27,sandshrew,300,ground 28,sandslash,450,ground 29,nidoran,275,poison 30,nidorina,365,poison 810,yeet,777,steel,fire,water,grass,electric,psychic,ice,dragon,dark,fairy,??? https://www.cs.montana.edu/paxton/classes/csci127/programs/program4/pokedex.txt Page 1 of 1 import string # # # # # # # # --------------------------------------CSCI 127, Joy and Beauty of Data | Program 4: Pokedex | Your Name(, Your Partner's Name) | Last Modified: ??, 2019 | --------------------------------------A brief overview of the program. --------------------------------------- # Your solution goes here ... # --------------------------------------# Do not change anything below this line # --------------------------------------def create_pokedex(filename): pokedex = [] file = open(filename, "r") for pokemon in file: pokelist = pokemon.strip().split(",") number = int(pokelist[0]) # number name = pokelist[1] # name combat_points = int(pokelist[2]) # hit points types = [] for position in range(3, len(pokelist)): types += [pokelist[position]] # type pokedex += [Pokemon(name, number, combat_points, types)] file.close() return pokedex # --------------------------------------def get_choice(low, high, message): legal_choice = False while not legal_choice: legal_choice = True answer = input(message) for character in answer: if character not in string.digits: legal_choice = False print("That is not a number, try again.") break if legal_choice: answer = int(answer) if (answer < low) or (answer > high): legal_choice = False print("That is not a valid choice, try again.") return answer # --------------------------------------def main(): pokedex = create_pokedex("pokedex.txt") choice = 0 while choice != 6: print_menu() choice = get_choice(1, 6, "Enter a menu option: ") if choice == 1: print_pokedex(pokedex) elif choice == 2: name = input("Enter a Pokemon name: ").lower() lookup_by_name(pokedex, name) elif choice == 3: number = get_choice(1, 1000, "Enter a Pokemon number: ") lookup_by_number(pokedex, number) elif choice == 4: pokemon_type = input("Enter a Pokemon type: ").lower() total_by_type(pokedex, pokemon_type) elif choice == 5: average_hit_points(pokedex) elif choice == 6: print("Thank you. Goodbye!") print() # --------------------------------------main() Program 4: Pokédex Logistics Due Date: Friday, March 15th no later than 11:59 p.m. Partner Information: You may complete this assignment individually or with exactly one partner. If you work with a partner, you must both be enrolled in the same lab section or you will both lose 10 points. Submission Instructions (working alone): Upload your solution, entitled YourFirstNameYourLastName-Program4.py to the BrightSpace Program 4 Dropbox. Submission Instructions (working with one lab mate): Upload your solution, renamed to YourFirstName-YourLastName-PartnerFirstName-PartnerLastName-Program4.py to the BrightSpace Program 4 Dropbox. Note: If you work with a partner, only one person needs to submit a solution. If you both submit a solution, the submission that will be graded is the one from the partner whose last name comes alphabetically first. Deadline Reminder: Once the submission deadline passes, BrightSpace will no longer accept your Python submission and you will no longer be able to earn credit. Thus, if you are not able to fully complete the assignment, submit whatever you have before the deadline so that partial credit can be earned. Learning Outcomes To solve this problem, you need to understand the following Python concepts: object-oriented programming and lists. Background Information The file pokedex.txt contains partial information about 31 Pokémon that mostly come from this Pokédex. Assignment Using pokedex.py as a starting point, supply the missing functions such that interaction with a user could produce this transcript. Grading - 100 points 20 points. The class Pokemon is defined (2 points) with the appropriate six methods (3 points each). 5 points. The function print_menu is correct. 10 points. The function print_pokedex is correct. 10 points. The function lookup_by_name is correct when the Pokémon is present (7 points) and absent (3 points). 10 points. The function lookup_by_number is correct when the number is present (7 points) and absent (3 points). 10 points. The function total_by_type is correct when the type is present (7 points) and absent (3 points). 10 points. The function average_hit_points is correct. 10 points. The format of the output matches the format of the output in the transcript exactly. (2 points for each type of difference up to 10 points.) 15 points - The Python solution is properly commented, easy to understand and does not contain unnecessary code. (3 points for each type of improvement up to 15 points.) 1. Print Pokedex 2. Print Pokemon by Name 3. Print Pokemon by Number 4. Count Pokemon with Type 5. Print Average Pokemon Combat Points 6. Quit Enter a menu option: 1 The Pokedex ----------Number: 1, Name: Bulbasaur, CP: 318: Type: grass and poison Number: 2, Name: Ivysaur, CP: 405: Type: grass and poison Number: 3, Name: Venusaur, CP: 525: Type: grass and poison Number: 4, Name: Charmander, CP: 309: Type: fire Number: 5, Name: Charmeleon, CP: 405: Type: fire Number: 6, Name: Charizard, CP: 534: Type: fire and flying Number: 7, Name: Squirtle, CP: 314: Type: water Number: 8, Name: Wartortle, CP: 405: Type: water Number: 9, Name: Blastoise, CP: 530: Type: water Number: 10, Name: Caterpie, CP: 195: Type: bug Number: 11, Name: Metapod, CP: 205: Type: bug Number: 12, Name: Butterfree, CP: 395: Type: bug and flying Number: 13, Name: Weedle, CP: 195: Type: bug and poison Number: 14, Name: Kakuna, CP: 205: Type: bug and poison Number: 15, Name: Beedrill, CP: 395: Type: bug and poison Number: 16, Name: Pidgey, CP: 251: Type: normal and flying Number: 17, Name: Pidgeotto, CP: 349: Type: normal and flying Number: 18, Name: Pidgeot, CP: 479: Type: normal and flying Number: 19, Name: Rattata, CP: 253: Type: normal Number: 20, Name: Raticate, CP: 413: Type: normal Number: 21, Name: Spearow, CP: 262: Type: normal and flying Number: 22, Name: Fearow, CP: 442: Type: normal and flying Number: 23, Name: Ekans, CP: 288: Type: poison Number: 24, Name: Arbok, CP: 448: Type: poison Number: 25, Name: Pikachu, CP: 320: Type: electric Number: 26, Name: Raichu, CP: 485: Type: electric and psychic Number: 27, Name: Sandshrew, CP: 300: Type: ground Number: 28, Name: Sandslash, CP: 450: Type: ground Number: 29, Name: Nidoran, CP: 275: Type: poison Number: 30, Name: Nidorina, CP: 365: Type: poison Number: 810, Name: Yeet, CP: 777: Type: steel and fire and water and grass and electric and psychic and ice and dragon and dark and fairy and ??? 1. 2. 3. 4. 5. 6. Print Print Print Count Print Quit Pokedex Pokemon Pokemon Pokemon Average by Name by Number with Type Pokemon Combat Points Enter a menu option: 2 Enter a Pokemon name: RAICHU Number: 26, Name: Raichu, CP: 485: Type: electric and psychic 1. 2. 3. 4. 5. 6. Print Print Print Count Print Quit Pokedex Pokemon Pokemon Pokemon Average by Name by Number with Type Pokemon Combat Points Enter a menu option: 2 Enter a Pokemon name: raichump There is no Pokemon named raichump 1. Print Pokedex 2. Print Pokemon by Name 3. Print Pokemon by Number 4. Count Pokemon with Type 5. Print Average Pokemon Combat Points 6. Quit Enter a menu option: 3 Enter a Pokemon number: 26 Number: 26, Name: Raichu, CP: 485: Type: electric and psychic 1. 2. 3. 4. 5. 6. Print Print Print Count Print Quit Pokedex Pokemon Pokemon Pokemon Average by Name by Number with Type Pokemon Combat Points Enter a menu option: 3 Enter a Pokemon number: 34 There is no Pokemon number 34 1. 2. 3. 4. 5. 6. Print Print Print Count Print Quit Pokedex Pokemon Pokemon Pokemon Average by Name by Number with Type Pokemon Combat Points Enter a menu option: 4 Enter a Pokemon type: Normal Number of Pokemon that contain type normal = 7 1. 2. 3. 4. 5. 6. Print Print Print Count Print Quit Pokedex Pokemon Pokemon Pokemon Average by Name by Number with Type Pokemon Combat Points Enter a menu option: 4 Enter a Pokemon type: ??? Number of Pokemon that contain type ??? = 1 1. 2. 3. 4. 5. 6. Print Print Print Count Print Quit Pokedex Pokemon Pokemon Pokemon Average by Name by Number with Type Pokemon Combat Points Enter a menu option: 4 Enter a Pokemon type: unknown Number of Pokemon that contain type unknown = 0 1. 2. 3. 4. 5. 6. Print Print Print Count Print Quit Pokedex Pokemon Pokemon Pokemon Average by Name by Number with Type Pokemon Combat Points Enter a menu option: 5 Average Pokemon combat points = 370.71 1. 2. 3. 4. 5. 6. Print Print Print Count Print Quit Pokedex Pokemon Pokemon Pokemon Average by Name by Number with Type Pokemon Combat Points Enter a menu option: 6 Thank you. Goodbye!
Purchase answer to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

I noticed this tricky teacher want...


Anonymous
Super useful! Studypool never disappoints.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Related Tags