Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sarahm44/lens-slice
Uses Python lists to organise sales data for a pizza store.
https://github.com/sarahm44/lens-slice
codecademy codecademy-courses codecademy-cs codecademy-pro python-lists python3
Last synced: 15 days ago
JSON representation
Uses Python lists to organise sales data for a pizza store.
- Host: GitHub
- URL: https://github.com/sarahm44/lens-slice
- Owner: sarahm44
- Created: 2025-01-29T10:35:00.000Z (17 days ago)
- Default Branch: main
- Last Pushed: 2025-01-29T11:07:27.000Z (16 days ago)
- Last Synced: 2025-01-29T11:34:08.526Z (16 days ago)
- Topics: codecademy, codecademy-courses, codecademy-cs, codecademy-pro, python-lists, python3
- Language: Python
- Homepage:
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Codecademy Project: Len's Slice
![""](https://github.com/sarahm44/lens-slice/blob/main/pizza.jpg)
## Overview
For this project, I imagine I work at Len’s Slice, a new pizza joint in the neighborhood. I use my knowledge of Python lists to organize some of my sales data.The Python notebook containing the code is [here](https://github.com/sarahm44/lens-slice/blob/main/lens_slices.py).
## Tasks
### Make Some Pizzas
1. To keep track of the kinds of pizzas you sell, create a list calledtoppings
that holds the following:*
"pepperoni"
*"pineapple"
*"cheese"
*"sausage"
*"olives"
*"anchovies"
*"mushrooms"
![""](https://github.com/sarahm44/lens-slice/blob/main/task_01.png)
2. To keep track of how much each kind of pizza slice costs, create a list called
prices
that holds the following integer values:*
2
*6
*1
*3
*2
*7
*2
![""](https://github.com/sarahm44/lens-slice/blob/main/task_02.png)
3. Your boss wants you to do some research on $2 slices. Count the number of occurrences of
2
in theprices
list, and store the result in a variable callednum_two_dollar_slices
. Print it out.![""](https://github.com/sarahm44/lens-slice/blob/main/task_03.png)
The code output is as follows:
![""](https://github.com/sarahm44/lens-slice/blob/main/output_03.png)
4. Find the length of the toppings list and store it in a variable called
num_pizzas
.![""](https://github.com/sarahm44/lens-slice/blob/main/task_04.png)
5. Print the string
We sell [num_pizzas] different kinds of pizza!
, where[num_pizzas]
represents the value of our variablenum_pizzas
.![""](https://github.com/sarahm44/lens-slice/blob/main/task_05.png)
The code output is as follows:
![""](https://github.com/sarahm44/lens-slice/blob/main/output_05.png)
6. Use the existing data about the pizza toppings and prices to create a new two-dimensional list called
pizza_and_prices
.Each sublist in
pizza_and_prices
should have one pizza topping and an associated price.| Price | Topping |
|----|----|
|2
|"pepperoni"
|
|6
|"pineapple"
|
|1
|"cheese"
|
|3
|"sausage"
|
|2
|"olives"
|
|7
|"anchovies"
|
|2
|"mushrooms"
|For this new list make sure the prices come before the topping name like so:
[price, topping_name]
Note: You don’t need to use your original
toppings
andprices
lists in this exercise. Create a new two-dimensional list from scratch.![""](https://github.com/sarahm44/lens-slice/blob/main/task_06.png)
7. Print
pizza_and_prices
.![""](https://github.com/sarahm44/lens-slice/blob/main/task_07.png)
The code output is as follows:
![""](https://github.com/sarahm44/lens-slice/blob/main/output_07.png)
### Sorting and Slicing Pizzas
8. Sortpizza_and_prices
so that the pizzas are in the order of increasing price (ascending).![""](https://github.com/sarahm44/lens-slice/blob/main/task_08.png)
The code output is as follows:
![""](https://github.com/sarahm44/lens-slice/blob/main/output_08.png)
9. Store the first element of
pizza_and_prices
in a variable calledcheapest_pizza
.![""](https://github.com/sarahm44/lens-slice/blob/main/task_09.png)
The code output is as follows:
![""](https://github.com/sarahm44/lens-slice/blob/main/output_09.png)
10. A man walks into the pizza store and shouts “I will have your MOST EXPENSIVE pizza!”
Get the last item of the
pizza_and_prices
list and store it in a variable calledpriciest_pizza
.![""](https://github.com/sarahm44/lens-slice/blob/main/task_10.png)
The code output is as follows:
![""](https://github.com/sarahm44/lens-slice/blob/main/output_10.png)
11. It looks like the most expensive pizza from the previous step was our very last
"anchovies"
slice. Remove it from ourpizza_and_prices
list since the man bought the last slice.![""](https://github.com/sarahm44/lens-slice/blob/main/task_11.png)
12. Since there is no longer an
"anchovies"
pizza, you want to add a new topping called"peppers"
to keep your customers excited about new toppings. Here is what your new topping looks like:
[2.5, "peppers"]
Add the new peppers pizza topping to our list
pizza_and_prices
.Note: Make sure to position it relative to the rest of the sorted data in
pizza_and_prices
, otherwise our data will not be correctly sorted anymore!![""](https://github.com/sarahm44/lens-slice/blob/main/task_12.png)
13. Three mice walk into the store. They don’t have much money (they’re mice), but they do each want different pizzas.
Slice the
pizza_and_prices
list and store the 3 lowest cost pizzas in a list calledthree_cheapest
.![""](https://github.com/sarahm44/lens-slice/blob/main/task_13.png)
14. Great job! The mice are very pleased and will be leaving you a 5-star review.
Print the
three_cheapest
list.![""](https://github.com/sarahm44/lens-slice/blob/main/task_14.png)
The code output is as follows:
![""](https://github.com/sarahm44/lens-slice/blob/main/output_14.png)