Skip to content

Latest commit

 

History

History
54 lines (32 loc) · 3.58 KB

File metadata and controls

54 lines (32 loc) · 3.58 KB

Len's Slice

You work at Len’s Slice, a new pizza joint in the neighborhood. Use your knowledge of Python lists to organize some of your sales data.

Remy eating pizza

Make Some Pizzas

A. To keep track of the kinds of pizzas you sell, create a list called toppings that holds the following:

"pepperoni"   "pineapple"   "cheese"   "sausage"   "olives"   "anchovies"   "mushrooms"

B. 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

C. Your boss wants you to do some research on $2 slices. Count the number of occurrences of 2 in the prices list, and store the result in a variable called num_two_dollar_slices. Print it out.

D. Find the length of the toppings list and store it in a variable called num_pizzas.

E. Print the string 'We sell num_pizzas different kinds of pizza!'. num_pizzas represents the value of our variable num_pizzas.

F. Convert our toppings and prices lists into a 2-dimensional list called pizza_and_prices that has the following associated values. Each sublist in pizza_and_prices should have one pizza topping and an associated price. For this project make sure the prices come before the topping name like so: [price, topping_name]

Price Topping: 2 "pepperoni"   6 "pineapple"   1 "cheese"   3 "sausage"   2 "olives"   7 "anchovies"   2 "mushrooms"


G. Print pizza_and_prices. Does it look the way you expect?

Sorting and Slicing Pizzas

H. Sort pizza_and_prices so that the pizzas are in order of increasing price (ascending).

I. Store the first element of pizza_and_prices in a variable called cheapest_pizza.

J. 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 called priciest_pizza.

K. It looks like the most expensive pizza from the previous step was our very last "anchovies" slice. Remove it from our pizza_and_prices list since the man bought the last slice.

L. 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!

M. Three mice walk into the store. They don’t have much money (they’re mice), but they do each want different pizzas.

O. Slice the pizza_and_prices list and store the 3 lowest cost pizzas in a list called three_cheapest.

P. Great job! 👍 The 🐁 are very pleased and will be leaving you a 5-star review.

Q. Print the three_cheapest list.