Assignment 8 part 0 warm up
Part 0: Warm-Up
Write a program that prompts the user to enter in a series of sales
figures for a 7 day period. The program should store these figures
in a list and then display the following data:
• Total sales for the week
• Average daily sales amount
• The best sales day
• The worst sales day
Ensure that the user enters in values that are 0 or greater. If not you
should ask them to re-enter the data for that day. Your program
should only accept valid integers (reject anything that isn't an
integer). Here’s an example running of this program:
Sales for day 1: 100
Sales for day 2: 200
Sales for day 3: one fifty
So
y, that is not a valid number. Please try again.
Sales for day 3: 150
Sales for day 4: 750
Sales for day 5: 99
Sales for day 6: 101
Sales for day 7: 125
Total sales: 1525
Average sales per day: 217.86
Highest sales day: 750 (day 4)
Lowest sales day: 99 (day 5)
Attempt the problem by building the following features, in this
order:
• Start off by collecting 7 price values. Don't wo
y about data
validation.
• You'll need to store these price values somewhere. There will
e 7 of them, so using 7 different variables will not be ideal.
Hint: use a list!
• After you have 7 price values compute the total & average.
• Next, compute the highest & lowest price
• Once all this works you can build in data validation. Hint: how
can you test to see if a value is numeric? is there something
that we covered last week with string mechanics that might
e useful here?
Assignment 8 part 1
Part 1: A
ay-ders of the Lost Ark!
Help Indiana "Python" Jones to solve a variety of list-based
challenges. The game can be found here
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 being asked. Submit your "scratch work"
solutions to the challenges, including all of the "passwords" you
obtain along the way, to Classes using the following filename:
GautamDhwani_assign8_part1.py)
https:
cs.nyu.edu/courses/fall21/CSCI-UA XXXXXXXXXX/PythonA
ayders/index.php
Assignment 8 part 2
Part 2a: 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 free to save all of your work in one big file
(call it "LastNameFirstName_assign8_part2.py")
Pokemon is a series of Japanese video games and related media
such as trading cards and television programs, featuring cartoon
monsters that are captured 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',
'gyrados']
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
elationship with the other list. For example, we have 3
'charmander' at our Pokemon center. The string 'charmander'
exists at position 0 in the first list, which relates the value at
position 0 in the second list (the integer 3).
And here's a sample running of your program:
Welcome to the Pokemon Center!
(s)earch by name or (q)uit: s
Name of Pokemon to search for: charmander
We have 3 Charmander at the Pokemon Center
Welcome to the Pokemon Center!
(s)earch by name or (q)uit: s
Name of Pokemon to search for: SQUIRTLE
We have 2 Squirtle at the Pokemon Center
Welcome to the Pokemon Center!
(s)earch by name or (q)uit: s
Name of Pokemon to search for: pikachu
We do not have any Pikachu at the Pokemon Center
Welcome to the Pokemon Center!
(s)earch by name or (q)uit: buy
Unknown command, please try again
Welcome to the Pokemon Center!
(s)earch by name or (q)uit: q
See you next time!
Some considerations for this part of the program:
• 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 first 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 Gyrados. Hint: you might want to create a new
list to store this data! - once 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.
• Ensure that this listing is formatted appropriately and will
always display in neatly in a tabular format. You will most
likely need to find the largest value in each column and format
that column accordingly. This doesn't need to be exact, but if
we enter a very large Pokemon name or adoption fee your
table should not "
eak".
Here's a sample running of your program:
Welcome to the Pokemon Center!
(s)earch by name, (l)ist or (q)uit: l
Name XXXXXXXXXXAmount Available Adoption Fee
Charmander XXXXXXXXXX XXXXXXXXXX
Squirtle XXXXXXXXXX XXXXXXXXXX
Bulbasaur XXXXXXXXXX XXXXXXXXXX
Gyrados XXXXXXXXXX XXXXXXXXXX,000.00
Welcome to the Pokemon Center!
(s)earch by name, (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
Welcome to the Pokemon Center!
(s)earch by name, (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 of type "Fire", Squirtle is of type
"Water", Bulbasaur is of type "Grass" and Gyrados has two types -
"Water" and "Flying". The following list contains these types
organized for each of the 4 Pokemon you cu
ently have in your
center:
pokemon_types = [['fire'], ['water'], ['grass'],
['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 ['grass'], and so on. We
efer 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
ackets. For example, to extract the value 'water' from the
list above you can do the following:
print(pokemon_types[3][0])
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
ecause 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!
(s)earch by name, (l)ist or (q)uit: s
Name of Pokemon to search for: charmander
We have 3 Charmander at the Pokemon Center
It will cost $100.00 to adopt this Pokemon
charmander has the following types: Fire
Welcome to the Pokemon Center!
(s)earch by name, (l)ist or (q)uit: s
Name of Pokemon to search for: gyrados
We have 1 Gyrados at the Pokemon Center
It will cost $1,000.00 to adopt this Pokemon
gyrados has the following types: Water Flying
Welcome to the Pokemon Center!
(s)earch by name, (l)ist or (q)uit: l
Name XXXXXXXXXXAmount Available Adoption Fee Type(s)
Charmander XXXXXXXXXX XXXXXXXXXXFire
Squirtle XXXXXXXXXX XXXXXXXXXXWater
Bulbasaur XXXXXXXXXX XXXXXXXXXXGrass
Gyrados XXXXXXXXXX XXXXXXXXXX,000.00 Water Flying
Welcome to the Pokemon Center!
(s)earch by name, (l)ist or (q)uit: q
See you next time!
Part 2d
Next build in a feature that allows the user to search by type of
Pokemon. The program should find 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. Here's a sample
unning of