Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in python please Pokemon are fantastic creatures that people like to catch and train. For this question, you will write a program that allows the

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

in python please

Pokemon are fantastic creatures that people like to catch and train. For this question, you will write a program that allows the user to keep track of the Pokemon they have caught, and then assemble a team from among the Pokemon caught that can be taken to the local Pokemon Gym for training. Your program will have three phases. Phase 1: The Hunt The first part of the program will simulate a pokemon hunt. Pokemon hunting can be tedious, so we are going to automate the process to build up a portfolio of twenty pokemon. Use the provided function simulate_pokemon_hunt() to check if a hunt was successful, and if it was successful, which pokemon was caught. The function returns the name of the pokemon caught as a string if the hunt was successful, or the empty string if the hunt was unsuccessful. Before moving on the the gym, you need to catch twenty pokemon. Every hunt has a 75% chance of finding a pokemon. The pokemon will be one of seven possible, randomly determined based on how common the are in the region. Record the total number of tries it took to catch 20 pokemon in an integer variable. Record the strings for each pokemon caught in a list called poke_list. Because of there are 20 pokemon caught, but only 7 types, your list should include several duplicates. You should write a function called pokemon_hunt that take the number of pokemon you wish to catch as a parameter and returns the number of hunts it took to catch those pokemon, as well as list containing the names of all the pokemon. Call simulate_pokemon_hunt() from inside your function. For your hand-in, call pokemon_hunt with a goal of catching 20 pokemon. Note 1 This is an example of a stochastic process, that is a process which is at least in part governed by chance. This means that we can't know before hand exactly how many tries it will take to get 20 pokemon (although it should be around 25), or exactly which pokemon we will get (although we would expect more Magikarps). Stochastic problems are common in computer science, and require building a degree of flex- ibility into your code to accommodate the uncertainty. In this relatively simple case, it informs which kind of loop you should use. Phase 2: Getting Sorted We've now got a backpack full of pokeballs containing various pokemon, but let's face it, it's a mess. It would be much better if things were organized. Fortunately, there is a function for that. Use the sort() method for lists to sort your pokemon alphabetically. Print out the alphabetized list. Now we are going to tally your pokemon by type. Create a function print-poke_counts that takes your sorted List of pokemon and counts the number of each type you have. For each pokemon you have in your list it should print to the console the name and number of pokemon. For example: Charmander 3 Eevee 1 Magikarp 12 Snorlax 4 Note 2 Our problem is no longer stochastic. We have a list of exactly 20 pokemon, and while that list was generated randomly, we know for certain that it is a list of 20 elements which must be strings. The problem is now deterministic. Note 3 This task is made substantially easier because we sorted the pokemon first. Tallying based on an unsorted list would have required a lot more work. While it doesn't matter for the small amount of data we are working with here, deciding whether to organize data before processing it is a common question in computer science, and often depends on the number of times you will need to access the organized data. Note 4 This task could output a dictionary of pokemon, count pairs (covered this week) to make the next section even easier. If you want to stretch yourself, your could try, but it is purely for personal interest, and is not part of the assignment. Phase 3: To The Gym! Time to put our pokemon through their paces. Take you pokemon to the gym to train. However, you can only train four pokemon at a time, so you will need to take them from your main roster and put them in a new list called team. Write a function called pokemon_team_select that allows Page 6 CMPT 141/113 UNIVERSITY OF SASKATCHEWAN Department of Computer Science 176 Thorvaldson Building 110 Science Place, Saskatoon, SK, S7N 5C9, Canada Telephine: (306) 966-4886, Facimile: (306) 966-4884 Winter 2021 Introduction to Computer Science the user to select which pokemon to take to the gym. This function should both manage the lists and do the input/output. Prompt the user to enter the name of the pokemon they wish to train. You can assume they type in the name correctly. Remove that pokemon from your poke_list and add it to team. Use the print_poke_counts function to output both the poke_list and team. Remember to sort your team before displaying it so your print_poke_counts works correctly. Continue until the the user has selected four pokemon to take to the gym. Your function should take the current poke_list and the number of pokemon on a team, and return a new poke_list and team. For your hand-in, use a pokemon team size of 4. Here is an example of how your program's console output might look. Green text was entered by the user. Phase 1: Time to catch some Pokemon! Hunt failed! You caught a Magikarp ! You caught a Eevee ! You caught a Squirtle ! Hunt failed! You caught a Magikarp ! Hunt failed! You caught a Magikarp ! Hunt failed! You caught a Snorlax ! You caught a Pikachu ! You caught a Eevee ! Hunt failed! You caught a Pikachu ! You caught a Charmander ! You caught a Dragonite ! You caught a Dragonite ! Hunt failed! Hunt failed! You caught a Charmander ! Hunt failed! You caught a Charmander ! Hunt failed! You caught a Magikarp ! You caught a Magikarp ! You caught a Charmander ! You caught a Snorlax ! Hunt failed! You caught a Magikarp ! You caught a Pikachu ! It took you 30 tries to catch 20 pokemon. ['Magikarp', 'Eevee', 'Squirtle', 'Magikarp', 'Magikarp', 'Snorlax', 'Pikachu', 'Eevee', 'Pikachu', 'Charmander', 'Dragonite', 'Dragonite', 'Charmander', Charmander', 'Magikarp' ' Magikarp', 'Charmander', 'Snorlax', 'Magikarp', 'Pikachu ') **** Phase 2: Time to get sorted ['Charmander', 'Charmander', 'Charmander', 'Charmander', 'Dragonite', 'Dragonite', 'Eevee', 'Eevee', 'Magikarp', 'Magikarp', 'Magikarp', 'Magikarp', 'Magikarp', 'Magikarp', 'Pikachu', 'Pikachu', 'Pikachu', 'Snorlax', 'Snorlax', 'Squirtle'] Charmander 4 Dragonite 2 Eevee 2 Magikarp 6 Pikachu 3 ***** Snorlax 2 Squirtle 1 Phase 3: Time to head to the Pokemon Gym ! What Pokemon will you add to your team? Squirtle I CHOOSE YOU, SQUIRTLE!! Pokemon in your collection: Charmander 4 Dragonite 2 Eevee 2 Magikarp 6 Pikachu 3 Snorlax 2 Pokemon on your Gym Team: Squirtle 1 What Pokemon will you add to your team? Dragonite I CHOOSE YOU, DRAGONITE!! Pokemon in your collection: Charmander 4 Dragonite 1 Eevee 2 Magikarp 6 Pikachu 3 Snorlax 2 Pokemon on your Gym Team: Dragonite 1 Squirtle 1 What Pokemon will you add to your team? Snorlax I CHOOSE YOU, SNORLAX!! Pokemon in your collection: Charmander 4 Dragonite 1 Eevee 2 Magikarp 6 Pikachu 3 Snorlax 1 Pokemon on your Gym Team: Dragonite 1 Snorlax 1 Squirtle 1 What Pokemon will you add to your team? Dragonite I CHOOSE YOU, DRAGONITE!! Pokemon in your collection: Charmander 4 Eevee 2 Magikarp 6 Pikachu 3 Snorlax 1 Pokemon on your Gym Team: Dragonite 2 Snorlax 1 Squirtle 1 Your Pokemon team is ready to hit the gym

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

T Sql Window Functions For Data Analysis And Beyond

Authors: Itzik Ben Gan

2nd Edition

0135861446, 978-0135861448

More Books

Students also viewed these Databases questions