Python The Hard Way exercise files.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

14 lines
469 B

toppings = ['pepperoni', 'pineapple', 'cheese', 'sausage', 'olives', 'anchovies', 'mushrooms']
prices = [2, 6, 1, 3, 2, 7, 2]
num_pizzas = len(toppings)
print("We sell " + str(num_pizzas) + " kinds of pizza!")
pizzas = list(zip(toppings, prices))
pizzas.sort(key=lambda x: x[1])
cheapest_pizza = pizzas[0]
priciest_pizza = pizzas[-1]
three_cheapest = pizzas[0:3]
print(pizzas)
print(three_cheapest)
num_two_dollar_slices = prices.count(2)
print(num_two_dollar_slices)