Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Assignment #8

For this assignment you will be writing 2 programs which should be saved independently. The lename you should use for each program is outlined in the sections below. When you're nished, you should submit your programs using the 'Assignments' tool in Brightspace.

You may work by yourself or with a partner. If you choose to work with someone else please be sure to give them credit in your source code and on Brightspace when you submit your work. Each member of a team must submit their own copy of the assignment to get credit for the assignment.

Part 1: Array-ders of the Lost Ark!

Help Indiana "Python" Jones to solve a variety of list-based challenges. The game can be found here -

.nyu.edu/elearning/CSCI_UA_0002/PythonArrayders/ .nyu.edu/elearning/CSCI_UA_0002/PythonArrayders/)https://cs(https://cs For this program you will not be writing a formal program with user input, etc. - you will simply be using Python as "scratch paper" to solve the problems bein asked. Submit your "scratch work" solutions to the challenges, including all of the "passwords" you obtain along the way, to NYU Classes using the following

lename: LastnameFirstname_assign8_part1.py (for example, KappCraig_assign8_part1.py)

Part 2: Pokemon Center Database

Note that the programs you will be writing for Part 2a through Part 2g build on one another. You will want to attempt these parts in order. You can also feel fre to save all of your work in one big le (call it "LastNameFirstName_assign8_part2.py")

Part 2a

Pokemon is a series of Japanese video games and related media such as trading cards and television programs, featuring cartoon monsters that are capture by players and trained to battle each other. In this program you will be helping to build a Pokemon database system for a Pokemon center.

To begin you will be creating a simple menu system that will allow the user to look up which Pokemon are available at your Pokemon Center. Given the following lists, write a program that asks the user for a Pokemon name. Next, find out if the Pokemon Center has that Pokemon and report the status to the user. Allow the user to continually inquire about product names until they elect to quit the program.

Here are some lists to get you started:

# Pokemon lists

pokemon_names = ['charmander', 'squirtle', 'bulbasaur', 'gyarados']

pokemon_amounts = [3, 2, 5, 1]

Note that these lists are related to one another - both lists have the same # of elements, and the position of each element indicates its relationship with the

other list. For example, we have 3 'charmander' at our Pokemon center. The string 'charmander' exists at position 0 in the rst list, which relates the value at position 0 in the second list (the integer 3).

Here's a sample running of your program. Note that the prompt contains a number of features that we haven't built yet. Don't worry about these features just yet -- we will be adding these in future parts of the assignment.

Welcome to the Pokemon Center!

(a)dd, (r)emove, r(e)port, (s)earch by name, search

Unknown command, please try again

by (t)ype, (l)ist

or (q)uit: hello world

Welcome to the Pokemon Center!

(a)dd, (r)emove, r(e)port, (s)earch by name, search

Name of Pokemon to search for: pikachu

by (t)ype, (l)ist

or (q)uit: s

We do not have any Pikachu at the Pokemon Center

Welcome to the Pokemon Center!

(a)dd, (r)emove, r(e)port, (s)earch by name, search

Name of Pokemon to search for: Squirtle

by (t)ype, (l)ist

or (q)uit: s

We have 2 Squirtle at the Pokemon Center

Welcome to the Pokemon Center!

(a)dd, (r)emove, r(e)port, (s)earch by name, search

Name of Pokemon to search for: SQUIRTLE

by (t)ype, (l)ist

or (q)uit: S

We have 2 Squirtle at the Pokemon Center

Welcome to the Pokemon Center!

(a)dd, (r)emove, r(e)port, (s)earch by name, search

Name of Pokemon to search for: CHarManDer

by (t)ype, (l)ist

or (q)uit: S

We have 3 Charmander at the Pokemon Center

Welcome to the Pokemon Center!

(a)dd, (r)emove, r(e)port, (s)earch by name, search

See you next time!

by (t)ype, (l)ist

or (q)uit: q

Some considerations for this part of the program:

Commands are case insensitive (i.e. 's' and 'S' are both valid for 'search')

Allow the user to type in any case variation of the Pokemon name (i.e. the strings 'CHARMANDER' and 'charmander' should both work when searching for that Pokemon)

When reporting the name of the Pokemon you should ensure that the rst character is capitalized (i.e. 'Charmander', 'Squirtle', 'Bulbasaur', etc.)

Part 2b

Next, extend your program so that it keeps track the "adoption fee" for each type of Pokemon. Default your adoption fees to be $100.00 for Charmander,       $50.00 for Squirtle, $25.00 for Bulbasaur and $1,000.00 for Gyarados. Hint: you might want to create a new list called  pokemon_fees to store this data! - onc you have this information in place you should modify your program to do the following:

Update the search feature to include a line to report the adoption fee for each Pokemon

Add a new feature that lists ALL Pokemon, their amounts and their adoption fees.

Standard credit: Format your table so that it lines up visually so that each column is exactly 20 characters wide. Column 1 should be left aligned, and columns 2 and 3 should be right aligned.

Extra credit: Format the columns so that they grow based on the contents of each list. The sizing of each column should appear as follows:

Column 1 ('Name'): aligned left, minimum length of 5 characters, can grow to the length of the longest string in the  pokemon_names list + 1 (i.e. if 'charmander' is the largest string in the list with 10 characters, so the column should be formatted to 11 characters wide)

Column 2 ('Amount Available'): aligned right, minimum length of 20 characters, can grow to the length of the largest integer in the  pokemon_amoun list + 1 (i.e. if the largest amount is 5 the column will be formatted to 20 characters long, but if the largest amount is 999999999999999999999999 (25 9's) the column would be formatted to 26 characters wide)

Column 3 ('Adoption Fee'): aligned right, minimum length of 15 characters, can grow to the length of the size of the largest formatted oat in the pokemon_fees list + 1. For example, if the largest oat in the list is 10000000000000000000.0 the formatted version (2 decimal points, comma  separator) would be ''10,000,000,000,000,000,000.00' -- this string has 29 characters, meaning that the column width should be 30.

Here's a sample running of your program (which shows the 'standard credit' version of the assignment)

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: gyarados

We have 1 Gyarados at the Pokemon Center

It will cost $1,000.00 to adopt this Pokemon

Welcome to the Pokemon Center!

(a)dd, (r)emove,

Name

Charmander

Squirtle

Bulbasaur

Gyarados

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!

Part 2c

Next, add in the ability to keep track of the "type" of each Pokemon. Each Pokemon has one or more "type" associated with it. For example, Charmander is o type "Fire", Squirtle is of type "Water", Bulbasaur has two types - "Grass" and "Poison", and Gyarados has two types - "Water" and "Flying". The following lis contains these types organized for each of the 4 Pokemon you currently have in your center:

pokemon_types = [['fire'], ['water'], ['grass', 'poison'], ['water', 'flying']]

Note how this is a "list of lists" - element 0 of the list is the little list ['fire']; element 1 of the list is the little list ['water'], and so on. We refer to this as a 'multi-  dimensional' list in computer programming. You can access lists inside of lists by using more than one set of square brackets. For example, to extract the val 'flying' from the list above you can do the following:

print(pokemon_types[3][1])

Your task is to incorporate this list into your program and report the "type" of each Pokemon when using the "search" and "list" features. Note that you probably don't need to format these types because they will be the last thing that you print on each line of output when using the "search" feature.       Here's a sample running of your program with these features 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: s

Name of Pokemon to search for: Squirtle

We have 2 Squirtle at the Pokemon Center

It will cost $50.00 to adopt this Pokemon

Squirtle has the following type(s): 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: GYARADOS

We have 1 Gyarados at the Pokemon Center

It will cost $1,000.00 to adopt this Pokemon

Gyarados has the following type(s): Water Flying

Welcome to the Pokemon Center!

r(e)port, (s)earch by name, search by (t)ype, (l)ist or (q)uit: l

Amount Available        Adoption Fee Type(s)

3              100.00 Fire

2               50.00 Water

5               25.00 Grass Poison

1            1,000.00 Water Flying

(a)dd, (r)emove,

Name

Charmander

Squirtle

Bulbasaur

Gyarados

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!

Note that for the "list" feature you are adding a new column. This column should be left aligned and doesn't need to be formatted to a specific size (it's the la column in the table and nothing comes after it)

Next build in a feature that allows the user to search by type of Pokemon. The program should nd all Pokemon of that type and display it using the "list"      interface that you built above. Hint: you might want to copy the code you wrote for that part and make some changes to it to handle this new feature. The sa column sizing rules apply for this (20 characters for standard credit, dynamic sizing for extra credit). Here's a sample running of this part of the program:

Welcome to the Pokemon Center!

(a)dd, (r)emove, r(e)port, (s)earch by

Enter Pokemon type: awesome

We have no Pokemon of that type at our

Welcome to the Pokemon Center!

(a)dd, (r)emove, r(e)port, (s)earch by

Enter Pokemon type: fire

Amount Available

3

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

Adoption Fee Type(s)

50.00 Water

1,000.00 Water Flying

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!

Part 2e

Next, add in an "add" feature that lets users add a new Pokemon to the center. When you add a product you will need to ask the user for the name of the     Pokemon, how many Pokemon the Center has available to sell, and the adoption fee. Validate this data - you cannot add a Pokemon that already exists and both the amount and cost must be positive.

In addition, the type must also be validated to be one of a small number of possible types. Here are all possible valid types for the purpose of your program:

valid_pokemon_types = ['bug', 'dark', 'dragon', 'electric', 'fairy', 'fighting', 'fire', 'flying', 'ghost', 'grass', 'ground', 'ice', 'normal'

Your program should allow the user to enter 1 or 2 types for each Pokemon. If the user requests it they should be able to access this list to see the valid types they can supply for a Pokemon. Use a sentinel value of "end" to stop accepting new Pokemon types or stop the prompting for types after the user enters 2    types. Hint: use an empty list to store your Pokemon types.

Here's a sample running of the program with this feature:

Welcome to the Pokemon Center!

(a)dd, (r)emove,

Name

Charmander

Squirtle

Bulbasaur

Gyarados

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: Squirtle

Duplicate name, add operation canceled

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: ButtERFree

How many of these Pokemon are you adding? -5

Invalid, please try again

How many of these Pokemon are you adding? -3

Invalid, please try again

How many of these Pokemon are you adding? 3

What is the adoption fee for this Pokemon? -50.72

Invalid, please try again

What is the adoption fee for this Pokemon? 0

Invalid, please try again

What is the adoption fee for this Pokemon? 25.12

Next you will be prompted to enter the types for this Pokemon. Pokemon can have 1 or 2 types. Type 'help' to view all possible Pokemon types, a

What type of Pokemon is this? help

* bug

* dark

* dragon

* electric

* fairy

* fighting

* fire

* flying

* ghost

* grass

* ground

* ice

* normal

* poison

* psychic

* rock

* steel

* water

What type of Pokemon is this? end

You must enter at least one valid type, please try again

What type of Pokemon is this? invisible

This is not a valid type, please try again

What type of Pokemon is this? bug

Type bug added

What type of Pokemon is this? FLYING

Type flying added

Pokemon added!

Welcome to the Pokemon Center!

(a)dd, (r)emove,

Name

Charmander

Squirtle

Bulbasaur

Gyarados

Butterfree

r(e)port, (s)earch by name, search by (t)ype, (l)ist or (q)uit: l

Amount Available        Adoption Fee Type(s)

3              100.00 Fire

2               50.00 Water

5               25.00 Grass Poison

1            1,000.00 Water Flying

3               25.12 Bug Flying

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: alakazam

How many of these Pokemon are you adding? 2