Question: I need unique python code for this question: Complete the below function that computes and returns the flight fare between two provided cities. The fare

I need unique python code for this question:

I need unique python code for this question: Complete the below function

Complete the below function that computes and returns the flight fare between two provided cities. The fare is computed using a complex algorithm as follows: There are cities, and there are hubs. A person can fly from one city to another city. Each city is connected to exactly one hub and there is an associated fixed fare for flying between the city and the hub. If the departure and destination cities are connected to the same hub, then the fares of both cities are summed up along with a fixed ticketing cost of 20, and the total becomes the fare of the flight. Flights between different hubs cost 200, ticketing included. So, if the departure and destination cities are connected to different hubs, then the total fare becomes the sum of the city fares plus 200. For example, the fare from city X to hub A is 75, the fare from city Y to hub B is 90, then the fare of the flight from X to Y becomes 75+90+200 = 365. However, if the cities were connected to the same hub, then the fare would be 75+90+20 = 185. However, there is one more catch. If the fares of both cities are less than 60, then a discount of 50 is applied to the total. This discount only applies when the cities are connected to different hubs. You will read all the fare information from a file called "fares.txt". This file is formatted as follows: A X 75 BY 90 CX 60 Each line contains the name of a city, the connected hub, and the corresponding fare. The example above contains flight information for three cities: A, B and C. Flight from city A to hub X costs 75, city B to hub y costs 90 and city X to hub X costs 60. def fareCalculator (cityi, city2): return # Remove this line only when you answer this

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!