Answered step by step
Verified Expert Solution
Link Copied!

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 read_records(fname):#TODOdef find_highest(obj_list):destinations =[x.destination for x in obj_list]max_destinations =[destinations[i] for i in range(len(destinations)) if fares[i]== max_fare]def display(data): returncities.sort()data = read_records("airfares.txt")
display(data)The 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 date/time of the flight, the origin city, the
destination city, and the airfare. Given the file "airfares.txt", complete the implementation of
read_records, and display for the program airfare_pro.py to fulfill the following functional
behavior:
The function read_records 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 : $486.85['Regina']
Edmonton : $500.24['Quebec City']
Fredericton : $499.21['Vancouver']
Halifax : $485.32['Ottawa', 'Whitehorse']
Iqaluit : $498.57['Edmonton']
London : $457.29['Edmonton']
Montreal : $499.63['Yellowknife']
Ottawa : $493.13['Victoria']
Quebec City : $499.21['0ttawa', 'Winnipeg']
Regina : $469.3['Windsor']
St John's : $495.38['Quebec City']
Toronto : $497.1['Edmonton']
Vancouver : $494.87['Montreal']
Victoria : $494.88['Vancouver']
Whitehorse : $496.88['Calgary']
Windsor : $486.19['Halifax']
Winnipeg : $498.28['Yellowknife']
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions

Question

Repeat Problem 2 for (a) 6 Li, (b) 39 K, (c) 208 Pb.

Answered: 1 week ago

Question

What is the formula to calculate the mth Fibonacci number?

Answered: 1 week ago