here you go
Assignment 10 part 0 Warm Up Given the following string, write a program that counts how many times each letter has been used in the string. Use a dictionary to store your results. phrase = "The lazy dog jumped over the curious cat." Here's a sample running of your program: Report by letter, in ascending order by ASCII value: T 1 a 2 c 2 d 2 e 4 g 1 h 2 i 1 j 1 l 1 m 1 o 3 p 1 r 2 s 1 t 2 u 3 v 1 y 1 z 1 This program should be named as follows: GautamDhwani_assign10_part0.py Assignment 10 part 1 Part 1 Note that the programs you will be writing build on one another. You will want to attempt these parts in order and save them as separate files to be safe (if you make a mistake in part 2b you don't want to undo your hard work with part 1a). When you are happy with your work you can submit all of your work in one big file (call it "GautamDhwani_assign10_part1_final.py") For this project you will be re-writing the "product database" program from Assignment 08 using dictionaries. This will help you to compare and contrast how dictionaries and lists operate in similar yet different ways. You'll also notice that some tasks tend to be much easier (and more efficient!) to write with dictionaries, while others may be more challenging. Part 1a valid_pokemon_types = ['bug', 'dark', 'dragon', 'electric', 'fairy', 'fighting', 'fire', 'flying', 'ghost', 'grass', 'ground', 'ice', 'normal', 'poison', 'psychic', 'rock', 'steel', 'water'] pokemon = { 'charmander': {'quantity':3,'fee':100,'powers':['fire']}, 'squirtle':{'quantity':2,'fee':50,'powers': ['water']}, 'bulbasaur':{'quantity':5,'fee':25,'powers': ['grass']}, 'gyrados':{'quantity':1,'fee':1000,'powers': ['water','flying']} } Each 'key' in the dictionary is a pokemon name (string). Each 'key' has a value (another dictionary) which contains the quantity of that pokemon, the adoption fee 'types' of that pokemon stored in a list. You can access pokemon in the dictionary using two sets of square brackets. For example: print ("we have", pokemon["charmander"]["quantity"], "at the center") Your task is to add the following functionality to this program: • Overarching menu system • List all pokemon • Search for a pokemon by name • Search for a pokemon by type • Add a pokemon • Remove a pokemon • Report on all pokemon Here's a sample running of this program (user input is underlined): Welcome to the Pokemon Center! (a)dd, (r)emove, r(e)port, (s)earch by name, search by (t)ype, (l)ist or (q)uit: l Name Amount Available Adoption Fee Type(s) Bulbasaur 5 25.00 Grass Charmander 3 100.00 Fire Gyrados 1 1,000.00 Water Flying Squirtle 2 50.00 Water Welcome to the Pokemon Center! (a)dd, (r)emove, r(e)port, (s)earch by name, search by (t)ype, (l)ist or (q)uit: a Enter name of new pokemon: pikachu How many of these Pokemon are you adding? 5 What is the adoption fee for this Pokemon? -10 Invalid, please try again What is the adoption fee for this Pokemon? 37.50 Next you will be prompted to enter the 'types' for this Pokemon. Pokemon can have multiple types. Type 'help' to view all possible Pokemon types, and type 'end' to stop entering types. You must enter at least one valid 'type' What type of Pokemon is this? electric Type electric applied What type of Pokemon is this? end Pokemon added! Welcome to the Pokemon Center! (a)dd, (r)emove, r(e)port, (s)earch by name, search by (t)ype, (l)ist or (q)uit: l Name Amount Available Adoption Fee Type(s) Bulbasaur 5 25.00 Grass Charmander 3 100.00 Fire Gyrados 1 1,000.00 Water Flying Pikachu 5 37.50 Electric Squirtle 2 50.00 Water Welcome to the Pokemon Center! (a)dd, (r)emove, r(e)port, (s)earch by name, search by (t)ype, (l)ist or (q)uit: s Name of Pokemon to search for: pikachu We have 5 Pikachu at the Pokemon Center It will cost $37.50 to adopt this Pokemon Pikachu has the following types: Electric Welcome to the Pokemon Center! (a)dd, (r)emove, r(e)port, (s)earch by name, search by (t)ype, (l)ist or (q)uit: t Enter Pokemon type: electric Name Amount Available Adoption Fee Type(s) Pikachu 5 37.50 Electric Welcome to the Pokemon Center! (a)dd, (r)emove, r(e)port, (s)earch by name, search by (t)ype, (l)ist or (q)uit: t Enter Pokemon type: water Name Amount Available Adoption Fee Type(s) Gyrados 1 1,000.00 Water Flying Squirtle 2 50.00 Water Welcome to the Pokemon Center! (a)dd, (r)emove, r(e)port, (s)earch by name, search by (t)ype, (l)ist or (q)uit: r Enter name of Pokemon to remove: eevee Pokemon not found, cannot remove Welcome to the Pokemon Center! (a)dd, (r)emove, r(e)port, (s)earch by name, search by (t)ype, (l)ist or (q)uit: r Enter name of Pokemon to remove: pikachu Pokemon removed Welcome to the Pokemon Center! (a)dd, (r)emove, r(e)port, (s)earch by name, search by (t)ype, (l)ist or (q)uit: l Name Amount Available Adoption Fee Type(s) Bulbasaur 5 25.00 Grass Charmander 3 100.00 Fire Gyrados 1 1,000.00 Water Flying Squirtle 2 50.00 Water Welcome to the Pokemon Center! (a)dd, (r)emove, r(e)port, (s)earch by name, search by (t)ype, (l)ist or (q)uit: e Highest priced Pokemon: Gyrados @ $1,000.00 per Pokemon Lowest priced Pokemon: Bulbasaur @ $25.00 per Pokemon Total cost to adopt all Pokemon in the Center: $1,525.00 Welcome to the Pokemon Center! (a)dd, (r)emove, r(e)port, (s)earch by name, search by (t)ype, (l)ist or (q)uit: q See you next time! Here are some hints on each part: • You may use the code you that you wrote for assignment #8 as a starting point • For all features that display more than one Pokemon you should ensure that the listing is presented in alphabetical order based on the name of the Pokemon • The 'SEARCH' feature should be fairly straightforward - the KEY in the dictionary is the name of the product. How can you test to see if a KEY is in a dictionary? • The 'LIST' feature should also be fairly easy. How do you iterate over all KEYS in a dictionary? • The 'ADD' feature should be easy as well. How do you add a new KEY / VALUE pair to a dictionary? What are you storing as a value to match the sample data given in the dictionary above? You need to make sure that the item is not in the dictionary already as a KEY before you add it. Note that prices must never fall below $0.00. Inventory must never fall below 0 or go above 100. • The 'REMOVE' feature should be straightforward. How do you delete a KEY / VALUE pair from a dictionary? • 'REPORT' will be the trickiest function to write. For this one you will need to find three things: ◦ The total cost of all items: This will require that you visit all items in the dictionary and maintain some kind of accumulator ◦ The highest priced item and the lowest priced item may be tricky since the 'max' function will not work on a dictionary. You may