A numeric look at Porsche car models

# Source: porsche.com, 13.05.2017 porsche_cars_data = { '718 Cayman': { # l/100km 'fuel_consumption': { 'city trip': 9.9, 'interurban travel': 6.0, 'combined': 7.4 }, 'emissions': 168, # g/km 'cyllinders': 4, 'capacity': 1983, # cm3 'power': 220, # kW 'by number of revolutions': 6500, # 1/min 'max torque': 380, #Nm 'max speed': 275, #km/h 'acceleration': 5.1, # s (0-100km/h) 'price': 52694 # EUR, VAT included }, '718 Cayman S': { 'fuel_consumption': { 'city trip': 10.7, 'interurban travel': 6.5, 'combined': 8.1 }, 'emissions': 184, 'cyllinders': 4, 'capacity': 2497, 'power': 257, 'by number of revolutions': 6500, 'max torque': 420, 'max speed': 285, 'acceleration': 4.6, 'price': 65189 }, '718 Boxter': { 'fuel_consumption': { 'city trip': 9.9, 'interurban travel': 6.0, 'combined': 7.4 }, 'emissions': 168, 'cyllinders': 4, 'capacity': 1988, 'power': 220, 'by number of revolutions': 6500, 'max torque': 380, 'max speed': 275, 'acceleration': 4.6, 'price': 54717 }, '718 Boxter S': { 'fuel_consumption': { 'city trip': 10.7, 'interurban travel': 6.5, 'combined': 8.1 }, 'emissions': 184, 'cyllinders': 4, 'capacity': 2497, 'power': 257, 'by number of revolutions': 6500, 'max torque': 420, 'max speed': 285, 'acceleration': 4.6, 'price': 67212 }, '911 Carrera': { 'fuel_consumption': { 'city trip': 11.7, 'interurban travel': 6.3, 'combined': 8.3 }, 'emissions': 190, 'cyllinders': 6, 'capacity': 2981, 'power': 272, 'by number of revolutions': 6500, 'max torque': 450, 'max speed': 295, 'acceleration': 4.6, 'price': 97914 }, '911 Carrera S': { 'fuel_consumption': { 'city trip': 12.2, 'interurban travel': 6.6, 'combined': 8.7 }, 'emissions': 199, 'cyllinders': 6, 'capacity': 2981, 'power': 309, 'by number of revolutions': 6500, 'max torque': 500, 'max speed': 308, 'acceleration': 4.3, 'price': 112075 }, '911 Carrera Cabriolet': { 'fuel_consumption': { 'city trip': 11.9, 'interurban travel': 6.5, 'combined': 8.5 }, 'emissions': 199, 'cyllinders': 6, 'capacity': 2981, 'power': 272, 'by number of revolutions': 6500, 'max torque': 450, 'max speed': 292, 'acceleration': 4.8, 'price': 111004 }, '911 Carrera S Cabriolet': { 'fuel_consumption': { 'city trip': 12.3, 'interurban travel': 6.7, 'combined': 8.8 }, 'emissions': 202, 'cyllinders': 6, 'capacity': 2981, 'power': 309, 'by number of revolutions': 6500, 'max torque': 500, 'max speed': 306, 'acceleration': 4.5, 'price': 125165 }, '911 Carrera 4': { 'fuel_consumption': { 'city trip': 12.2, 'interurban travel': 6.7, 'combined': 8.7 }, 'emissions': 201, 'cyllinders': 6, 'capacity': 2981, 'power': 272, 'by number of revolutions': 6500, 'max torque': 450, 'max speed': 292, 'acceleration': 4.5, 'price': 105292 }, '911 Carrera 4S': { 'fuel_consumption': { 'city trip': 12.4, 'interurban travel': 6.8, 'combined': 8.9 }, 'emissions': 204, 'cyllinders': 6, 'capacity': 2981, 'power': 309, 'by number of revolutions': 6500, 'max torque': 500, 'max speed': 305, 'acceleration': 4.2, 'price': 119453 }, '911 Carrera 4 Cabriolet': { 'fuel_consumption': { 'city trip': 12.4, 'interurban travel': 6.9, 'combined': 8.9 }, 'emissions': 206, 'cyllinders': 6, 'capacity': 2981, 'power': 272, 'by number of revolutions': 6500, 'max torque': 450, 'max speed': 289, 'acceleration': 4.7, 'price': 118382 }, '911 Carrera 4S Cabriolet': { 'fuel_consumption': { 'city trip': 12.6, 'interurban travel': 6.8, 'combined': 9.0 }, 'emissions': 208, 'cyllinders': 6, 'capacity': 2981, 'power': 309, 'by number of revolutions': 6500, 'max torque': 500, 'max speed': 303, 'acceleration': 4.4, 'price': 132543 }, '911 Targa 4': { 'fuel_consumption': { 'city trip': 12.4, 'interurban travel': 6.9, 'combined': 8.9 }, 'emissions': 206, 'cyllinders': 6, 'capacity': 2981, 'power': 272, 'by number of revolutions': 6500, 'max torque': 450, 'max speed': 289, 'acceleration': 4.7, 'price': 118382 }, '911 Targa 4S': { 'fuel_consumption': { 'city trip': 12.6, 'interurban travel': 6.8, 'combined': 9.0 }, 'emissions': 208, 'cyllinders': 6, 'capacity': 2981, 'power': 309, 'by number of revolutions': 6500, 'max torque': 500, 'max speed': 303, 'acceleration': 4.4, 'price': 132543 }, '911 Turbo': { 'fuel_consumption': { 'city trip': 11.8, 'interurban travel': 7.5, 'combined': 9.1 }, 'emissions': 212, 'cyllinders': 6, 'capacity': 3800, 'power': 397, 'by number of revolutions': 6400, 'max torque': 660, 'max speed': 320, 'acceleration': 3.0, 'price': 176930 }, '911 Turbo S': { 'fuel_consumption': { 'city trip': 11.8, 'interurban travel': 7.5, 'combined': 9.1 }, 'emissions': 212, 'cyllinders': 6, 'capacity': 3800, 'power': 427, 'by number of revolutions': 6750, 'max torque': 700, 'max speed': 330, 'acceleration': 2.9, 'price': 205133 }, '911 Turbo Cabriolet': { 'fuel_consumption': { 'city trip': 12.1, 'interurban travel': 7.6, 'combined': 9.3 }, 'emissions': 216, 'cyllinders': 6, 'capacity': 3800, 'power': 397, 'by number of revolutions': 6400, 'max torque': 660, 'max speed': 320, 'acceleration': 3.1, 'price': 190020 }, '911 Turbo S Cabriolet': { 'fuel_consumption': { 'city trip': 12.1, 'interurban travel': 7.6, 'combined': 9.3 }, 'emissions': 216, 'cyllinders': 6, 'capacity': 3800, 'power': 427, 'by number of revolutions': 6750, 'max torque': 700, 'max speed': 330, 'acceleration': 3.0, 'price': 218223 }, '911 GT3 RS': { 'fuel_consumption': { 'city trip': 19.2, 'interurban travel': 8.9, 'combined': 12.7 }, 'emissions': 296, 'cyllinders': 6, 'capacity': 3996, 'power': 368, 'by number of revolutions': 8250, 'max torque': 460, 'max speed': 310, 'acceleration': 3.3, 'price': 181690 }, 'Panamera 4S': { 'fuel_consumption': { 'city trip': 10.2, 'interurban travel': 6.8, 'combined': 8.2 }, 'emissions': 186, 'cyllinders': 6, 'capacity': 2894, 'power': 324, 'by number of revolutions': 6125, 'max torque': 550, 'max speed': 289, 'acceleration': 4.4, 'price': 115050 }, 'Panamera 4S Diesel': { 'fuel_consumption': { 'city trip': 7.9, 'interurban travel': 5.9, 'combined': 6.8 }, 'emissions': 178, 'cyllinders': 8, 'capacity': 3956, 'power': 310, 'by number of revolutions': 4250, 'max torque': 850, 'max speed': 285, 'acceleration': 4.5, 'price': 118977 }, 'Panamera 4 E-Hybrid': { 'fuel_consumption': { 'city trip': None, 'interurban travel': None, 'combined': 2.5 }, 'emissions': 56, 'cyllinders': 6, 'capacity': 2894, 'power': 293, 'by number of revolutions': 5875, 'max torque': 650, 'max speed': 278, 'acceleration': 4.6, 'price': 109219 }, 'Panamera Turbo': { 'fuel_consumption': { 'city trip': 12.9, 'interurban travel': 7.3, 'combined': 9.4 }, 'emissions': 214, 'cyllinders': 8, 'capacity': 3996, 'power': 404, 'by number of revolutions': 5875, 'max torque': 770, 'max speed': 306, 'acceleration': 3.8, 'price': 155748 }, 'Macan': { 'fuel_consumption': { 'city trip': 8.6, 'interurban travel': 6.6, 'combined': 7.4 }, 'emissions': 172, 'cyllinders': 4, 'capacity': 1984, 'power': 185, 'by number of revolutions': 5900, 'max torque': 370, 'max speed': 229, 'acceleration': 6.7, 'price': 56264 }, 'Macan S': { 'fuel_consumption': { 'city trip': 11.6, 'interurban travel': 7.6, 'combined': 9.0 }, 'emissions': 212, 'cyllinders': 6, 'capacity': 2997, 'power': 250, 'by number of revolutions': 6000, 'max torque': 460, 'max speed': 254, 'acceleration': 5.4, 'price': 61738 }, 'Macan S Diesel': { 'fuel_consumption': { 'city trip': 6.9, 'interurban travel': 5.9, 'combined': 6.3 }, 'emissions': 164, 'cyllinders': 6, 'capacity': 2967, 'power': 190, 'by number of revolutions': 4125, 'max torque': 580, 'max speed': 230, 'acceleration': 6.3, 'price': 61143 }, 'Macan GTS': { 'fuel_consumption': { 'city trip': 11.8, 'interurban travel': 7.8, 'combined': 9.2 }, 'emissions': 164, 'cyllinders': 6, 'capacity': 2997, 'power': 265, 'by number of revolutions': 6000, 'max torque': 500, 'max speed': 256, 'acceleration': 5.2, 'price': 74828 }, 'Macan Turbo': { 'fuel_consumption': { 'city trip': 11.8, 'interurban travel': 7.8, 'combined': 9.2 }, 'emissions': 216, 'cyllinders': 6, 'capacity': 3604, 'power': 294, 'by number of revolutions': 6000, 'max torque': 550, 'max speed': 266, 'acceleration': 4.8, 'price': 84586 }, 'Cayenne Diesel': { 'fuel_consumption': { 'city trip': 7.8, 'interurban travel': 6.2, 'combined': 6.8 }, 'emissions': 179, 'cyllinders': 6, 'capacity': 2967, 'power': 193, 'by number of revolutions': 4000, 'max torque': 580, 'max speed': 221, 'acceleration': 7.3, 'price': 70663 }, 'Cayenne S': { 'fuel_consumption': { 'city trip': 13.0, 'interurban travel': 8.0, 'combined': 9.8 }, 'emissions': 229, 'cyllinders': 6, 'capacity': 3604, 'power': 309, 'by number of revolutions': 6000, 'max torque': 550, 'max speed': 259, 'acceleration': 5.5, 'price': 85082 }, 'Cayenne S Diesel': { 'fuel_consumption': { 'city trip': 10.3, 'interurban travel': 7.2, 'combined': 8.2 }, 'emissions': 215, 'cyllinders': 8, 'capacity': 4134, 'power': 283, 'by number of revolutions': 3750, 'max torque': 850, 'max speed': 252, 'acceleration': 5.4, 'price': 88275 }, 'Cayenne S E-Hybrid': { 'fuel_consumption': { 'city trip': None, 'interurban travel': None, 'combined': 3.4 }, 'emissions': 79, 'cyllinders': 6, 'capacity': 2995, 'power': 280, 'by number of revolutions': 5500, 'max torque': 590, 'max speed': 243, 'acceleration': 5.9, 'price': 86966 }, 'Cayenne GTS': { 'fuel_consumption': { 'city trip': 13.2, 'interurban travel': 8.3, 'combined': 10.0 }, 'emissions': 234, 'cyllinders': 6, 'capacity': 3604, 'power': 324, 'by number of revolutions': 6000, 'max torque': 600, 'max speed': 262, 'acceleration': 5.2, 'price': 102555 }, 'Cayenne Turbo': { 'fuel_consumption': { 'city trip': 15.9, 'interurban travel': 8.9, 'combined': 11.5 }, 'emissions': 267, 'cyllinders': 8, 'capacity': 4803, 'power': 382, 'by number of revolutions': 6000, 'max torque': 750, 'max speed': 279, 'acceleration': 4.5, 'price': 132781 }, 'Cayenne Turbo S': { 'fuel_consumption': { 'city trip': 15.9, 'interurban travel': 8.9, 'combined': 11.5 }, 'emissions': 267, 'cyllinders': 8, 'capacity': 4806, 'power': 419, 'by number of revolutions': 6000, 'max torque': 800, 'max speed': 284, 'acceleration': 4.1, 'price': 170504 }, } """ Goal: Find the most nature-friendly model (least emissions), least consuming model, fastest model, fastest acceleration model, max power per revolution model, least expensive model, most expensive model, best performance/price model NOTE: Here we'll define performance/price as (capacity_normalized * power_normalized * max_speed_normalized) / price_normalized, where mormalized values are in the interval [0,1]. Your definition may vary. Where the manufacturer has given a range of values for a given attribute, the average value has been taken. The prices are the starting prices for each model (extras excluded). For more information, visit the manufacturer's website. """ least_emissions_model = least_consuming_model = fastest_model = fastest_acceleration_model = max_power_per_revolution_model = least_expensive_model = most_expensive_model = best_performance_price_model = '' emissions = fuel_consumption_combined = min_price = min_acceleration_time = float('inf') max_capacity = max_power = max_power_per_revolution = max_speed = max_price = performance_price_ratio = 0 for model, data in porsche_cars_data.items(): if data['emissions'] < emissions: least_emissions_model, emissions = model, data['emissions'] if data['fuel_consumption']['combined'] < fuel_consumption_combined: least_consuming_model, fuel_consumption_combined = model, data['fuel_consumption']['combined'] if data['max speed'] > max_speed: fastest_model, max_speed = model, data['max speed'] if data['acceleration'] < min_acceleration_time: fastest_acceleration_model, min_acceleration_time = model, data['acceleration'] if data['price'] < min_price: least_expensive_model, min_price = model, data['price'] power_per_revolution = data['power'] / data['by number of revolutions'] if power_per_revolution > max_power_per_revolution: max_power_per_revolution_model, max_power_per_revolution = model, power_per_revolution # Needed for performance/price estimate if data['capacity'] > max_capacity: max_capacity = data['capacity'] if data['power'] > max_power: max_power = data['power'] if data['price'] > max_price: most_expensive_model, max_price = model, data['price'] for model, data in porsche_cars_data.items(): capacity_normalized = data['capacity'] / max_capacity power_normalized = data['power'] / max_power max_speed_normalized = data['max speed'] / max_speed price_normalized = data['price'] / max_price ratio = (capacity_normalized * power_normalized * max_speed_normalized) / price_normalized if ratio > performance_price_ratio: best_performance_price_model, performance_price_ratio, performance_price_euro = model, ratio, data['price'] print(""" Least emissions model: {least_emissions_model}, {emissions}g/km Least consuming model: {least_consuming_model}, {consumption}l/100km Fastest model: {fastest_model}, {max_speed}km/h Fastest acceleration model: {fastest_acceleration_model}, {min_acceleration_time}s (0-100km/h) Max power/revolution model: {max_power_per_revolution_model}, {max_power_per_revolution} kW/(1/min) Least expensive model: {least_expensive_model}, {min_price} Euro Most expensive model: {most_expensive_model}, {max_price} Euro Best performance/price model: {best_performance_price_model}, Ratio: {performance_price_ratio}, {performance_price_euro} Euro """.format(**{ 'least_emissions_model': least_emissions_model, 'emissions': emissions, 'least_consuming_model': least_consuming_model, 'consumption': fuel_consumption_combined, 'fastest_model': fastest_model, 'max_speed': max_speed, 'fastest_acceleration_model': fastest_acceleration_model, 'min_acceleration_time': min_acceleration_time, 'max_power_per_revolution_model': max_power_per_revolution_model, 'max_power_per_revolution': round(max_power_per_revolution, 4), 'least_expensive_model': least_expensive_model, 'min_price': min_price, 'most_expensive_model': most_expensive_model, 'max_price': max_price, 'best_performance_price_model': best_performance_price_model, 'performance_price_ratio': round(performance_price_ratio, 4), 'performance_price_euro': performance_price_euro })) """ Least emissions model: Panamera 4 E-Hybrid, 56g/km Least consuming model: Panamera 4 E-Hybrid, 2.5l/100km Fastest model: 911 Turbo S Cabriolet, 330km/h Fastest acceleration model: 911 Turbo S, 2.9s (0-100km/h) Max power/revolution model: Cayenne S Diesel, 0.0755 kW/(1/min) Least expensive model: 718 Cayman, 52694 Euro Most expensive model: 911 Turbo S Cabriolet, 218223 Euro Best performance/price model*: Cayenne Turbo, Ratio: 1.2423, 132781 Euro * Make sure you have reviewed the note above """