Comparing pizza prices at pizzerias

class Pizza: def __init__(self, name, weight, price): self.name = name self.weight = float(weight) self.price = float(price) def price_per_weight(self): return self.price/self.weight # pizza name, weight (g), price pizzeria_A = """ Margherita, 0.3, 3.9 Margherita, 0.45, 5.1 Funghi, 0.35, 4.1 Funghi, 0.5, 5.4 Italy, 0.45, 6.1 Italy, 0.65, 7.7 Palermo, 0.45, 6.2 Palermo, 0.65, 7.7 Roma, 0.4, 6.2 Roma, 0.6, 7.7 Vegetariana, 0.57, 5.6 Vegetariana, 0.85, 7.0 Salsice, 0.4, 5.6 Salsice, 0.6, 7.0 Uncle Scrooge, 0.5, 6.1 Uncle Scrooge, 0.7, 7.7 Picantina, 0.4, 6.1 Picantina, 0.6, 7.7 Sandrini, 0.35, 6.3 Sandrini, 0.5, 8.0 Di Spinaci, 0.45, 6.2 Di Spinaci, 0.65, 7.8 Caterina, 0.4, 6.2 Caterina, 0.6, 7.7 Nikita, 0.47, 6.2 Nikita, 0.67, 7.7 Paradise, 0.46, 6.5 Paradise, 0.67, 8.2 Mexicana, 0.50, 6.1 Mexicana, 0.75, 7.7 Quattro Formaggi, 0.45, 6.5 Quattro Formaggi, 0.60, 8.2 Calzone, 0.5, 6.8 Calzone, 0.7, 8.4 Pavarotti, 0.5, 6.2 Pavarotti, 0.7, 7.7 Vulcan, 0.45, 6.5 Vulcan, 0.7, 8.0 Prosciutto, 0.35, 6.9 Prosciutto, 0.5, 8.9 Torino, 0.4, 6.1 Torino, 0.6, 7.5 Laguna, 0.3, 6.9 Laguna, 0.45, 7.7 Puerto Rico, 0.37, 6.2 Puerto Rico, 0.57, 7.9 Tweetie, 0.4, 6.1 Tweetie, 0.57, 8.2 Mozarella, 0.4, 6.2 Mozarella, 0.6, 7.8 Quattro staggioni, 0.5, 6.5 Quattro staggioni, 0.65, 8.0 """ pizzeria_B = """ Teriaki, 0.55, 8.9 Teriaki, 1.5, 19 Sea breeze, 0.55, 9.8 Sea breeze, 1.5, 20 Family, 2.5, 29.9 For friends, 2.5, 29.9 Red hot plateau, 2.5, 29.9 Columbia, 0.55, 8.9 Columbia, 1.5, 21.99 Balcana, 0.55, 8.9 Balcana, 1.5, 20 Vegas, 0.55, 7.9 Vegas, 1.5, 18 Italiano, 0.55, 8.9 Italiano, 1.5, 20 Quartet Serena, 0.55, 7.9 Quartet Serena, 1.5, 18 Pepperoni, 0.55, 8.9 Pepperoni, 1.5, 20 Greek, 0.55, 7.9 Greek, 1.5, 18 Carbonara, 0.55, 8.9 Carbonara, 1.5, 19 Rio, 0.55, 8.9 Rio, 1.5, 22 Vegetariana, 0.55, 6.9 Vegetariana, 1.5, 15 Roma, 0.55, 7.9 Roma, 1.5, 16 Prosciutto, 0.55, 9.8 Prosciutto, 1.5, 20 Margherita, 0.4, 6.9 Margherita, 1.2, 12 """ pizzeria_C = """ Como, 0.54, 13.4 Imola, 0.45, 6.6 Crotone, 0.42, 9.1 Luca, 0.42, 8.2 Asti, 0.42, 9.9 Tivali, 0.42, 9.2 Catano, 0.46, 8.9 Tartufo, 0.42, 14.8 Ratatouille, 0.42, 7.3 Diablo, 0.46, 6.4 Margherita, 0.35, 3.9 Pepperoni, 0.45, 8.9 Four types of cheese, 0.46, 7.6 Pizza C, 0.75, 12.8 Polo, 0.48, 8.6 Calcone, 0.5, 9.4 Macho, 0.45, 8.2 Caprese, 0.48, 7.3 Rural, 0.46, 8.1 Thuna, 0.5, 13.8 Staggioni, 0.5, 9.9 """ pizzeria_D = """ El Mafiozo, 1.5, 19.7 El Mafiozo, 0.5, 8.9 El Mafiozo, 0.3, 5.9 Veritas, 1.5, 19.7 Veritas, 0.5, 8.9 Veneciana, 1.5, 16.0 Veneciana, 0.5, 7.15 Selena, 1.5, 18.7 Selena, 0.5, 8.7 Italia, 0.5, 7.15 """ from statistics import median, mean pizzerias = [pizzeria_A, pizzeria_B, pizzeria_C, pizzeria_D] median_prices = [-1,-1,-1,-1] mean_prices = [-1,-1,-1,-1] for i, pizzeria in enumerate(pizzerias): price_weights = [] for row in pizzeria.split('\n')[1:-1]: name, weight, price = row.split(', ') price_weights.append(Pizza(name, weight, price).price_per_weight()) price_weights.sort() median_prices[i] = median(price_weights) mean_prices[i] = mean(price_weights) print(median_prices) # [13.0, 13.333333333333334, 18.8, 14.3] print(mean_prices) # [13.562828481586164, 13.940376492194673, 19.60442971069265, 15.066666666666666]

We can see that in both cases, pizzeria A offers slightly lower prices (as a whole) than its competitors. If we assume that the quality of the food is comparable (which is subjective), then pizzeria A would have a price advantage. We also see that pizzeria A offers 52 pizza variants in total, which is considerably more than the 33, 21 and 10 variants of the other pizzerias. This suggests that achieving economies of scale could allow pizzeria owners to reduce their costs and offer people more for their money, which in turn expands their client base and allows them to experiment with new pizza flavours.