Answered step by step
Verified Expert Solution
Question
1 Approved Answer
class Flight: self.fdate = fdate self.origin = origin self.fare = fare def read _ records ( fname ) :#TODOdef find _ highest ( obj _
class Flight: self.fdate fdate self.origin origin self.fare fare
def readrecordsfname:#TODOdef findhighestobjlist:destinations xdestination for x in objlistmaxdestinations destinationsi for i in rangelendestinations if faresi maxfaredef displaydata: returncities.sortdata readrecordsairfarestxt
displaydataThe attached file "airfares.txt contains the records of airfares posted by an airline for flights
between Canadian cities. Each record is placed on a separate line, and consists of comma
separated fields containing from left to right the datetime of the flight, the origin city, the
destination city, and the airfare. Given the file "airfares.txt complete the implementation of
readrecords, and display for the program airfarepro.py to fulfill the following functional
behavior:
The function readrecords shall read airfare data records from the file airfares.txt and store
them in a dictionary with origin cities as keys and Flight objects as values.
The function display shall display for each origin city the highest fare of departing flights and
corresponding destinations. Origin cities must be listed in alphabetic order as illustrated by the
expected output of the program for the provided file, given below:Charlottetown : $Regina
Edmonton : $Quebec City'
Fredericton : $Vancouver
Halifax : $Ottawa 'Whitehorse'
Iqaluit : $Edmonton
London : $Edmonton
Montreal : $Yellowknife
Ottawa : $Victoria
Quebec City : $ttawa', 'Winnipeg'
Regina : $Windsor
St John's : $Quebec City'
Toronto : $Edmonton
Vancouver : $Montreal
Victoria : $Vancouver
Whitehorse : $Calgary
Windsor : $Halifax
Winnipeg : $Yellowknife
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started