Question: Please complete get_airport_info function. from typing import Dict, List, Set, Tuple from flight_reader import AirportDict, RouteDict, AIRPORT_DATA_INDEXES def get_airport_info (airports: AirportDict, iata: str, info: str)

Please complete get_airport_info function.

from typing import Dict, List, Set, Tuple from flight_reader import AirportDict, RouteDict, AIRPORT_DATA_INDEXES def get_airport_info(airports: AirportDict, iata: str, info: str) -> str:   """Return the airport information for airport with IATA code iata for   column info from AIRPORT_DATA_INDEXES.   >>> get_airport_info(TEST_AIRPORTS_DICT, 'AA1', 'Name')   'Apt1'   >>> get_airport_info(TEST_AIRPORTS_DICT, 'AA4', 'IATA')   'AA4'   """   # Complete the function body 

HELPFUL PY. FILE THAT YOU NEED:

flight_types_constants_and_test_data.py

# START: STARTER CODE from typing import Dict, List, Set, Union # The IATA code -> list of airport info for that airport. AirportDict = Dict[str, List[str]] # The source IATA airport code -> the set of reachable destination IATA # airport codes. RouteDict = Dict[str, Set[str]] # A directory of all flights, where a flight is a list of strings Flight = List[Union[str, float]] FlightDir = List[Flight] # Index information for airport data. AIRPORT_DATA_INDEXES = { "Airport ID": 0, "Name": 1, "City": 2, "Country": 3, "IATA": 4, "ICAO": 5, "Latitude": 6, "Longitude": 7, "Altitude": 8, "Timezone": 9, "DST": 10, "Tz": 11, "Type": 12, "Source": 13, } # Index information for route data. ROUTE_DATA_INDEXES = { "Airline": 0, "Airline ID": 1, "Source airport": 2, "Source airport ID": 3, "Destination airport": 4, "Destination airport ID": 5, "Codeshare": 6, "Stops": 7, "Equipment": 8, } # Index information for flight data. FLIGHT_DATA_INDEXES = { "Flight ID": 0, "Source airport": 1, "Destination airport": 2, "Departure time": 3, "Duration": 4, } """Test data for use in the doctests in flight_reader and flight_functions """ # 5 airports in 5 different countries. A StringIO object can use this as an # input source for purposes of testing. TEST_AIRPORTS_SRC = '''1,"Apt1","Cty1","Cntry1","AA1","AAA1",-1,1,1,1,"1","D1","Typ1","Src1" 2,"Apt2","Cty2","Cntry2","AA2","AAA2",-2,2,2,2,"2","D2","Type2","Src2" 3,"Apt3","Cty3","Cntry3","AA3","AAA3",-3,3,3,3,"3","D3","Type3","Src3" 4,"Apt4","Cty4","Cntry4","AA4","AAA4",-4,4,4,4,"4","D4","Type4","Src4" 5,"Apt5","Cty5","Cntry5","\\N","AAA5",-5,5,5,5,"5","D5","Type5","Src5"''' # Airport information for the airports in TEST_AIRPORTS_SRC. TEST_AIRPORTS_DICT = { "AA1": [ "1", "Apt1", "Cty1", "Cntry1", "AA1", "AAA1", "-1", "1", "1", "1", "1", "D1", "Typ1", "Src1", ], "AA2": [ "2", "Apt2", "Cty2", "Cntry2", "AA2", "AAA2", "-2", "2", "2", "2", "2", "D2", "Type2", "Src2", ], "AA3": [ "3", "Apt3", "Cty3", "Cntry3", "AA3", "AAA3", "-3", "3", "3", "3", "3", "D3", "Type3", "Src3", ], "AA4": [ "4", "Apt4", "Cty4", "Cntry4", "AA4", "AAA4", "-4", "4", "4", "4", "4", "D4", "Type4", "Src4", ], } # Routes between the tests airports. A StringIO object can use this as an # input source for purposes of testing. # The graph is: 1->2, 2->3, 3->4, 4->1, 1->4, and 3->1 TEST_ROUTES_SRC = """A1,1111,AA1,1,AA2,2,,0,EQ1 A2,2222,AA2,2,AA3,3,,0,EQ1 A3,3333,AA3,3,AA4,4,,0,EQ1 A4,4444,AA4,4,AA1,1,,0,EQ1 A1,1111,AA1,1,AA4,4,,0,EQ1 A3,3333,AA3,3,AA1,1,,0,EQ1 """ # The flight routes for the routes in TEST_ROUTES_SRC. TEST_ROUTES_DICT_FOUR_CITIES = { "AA1": {"AA2", "AA4"}, "AA2": {"AA3"}, "AA3": {"AA4", "AA1"}, "AA4": {"AA1"}, } # Flights between the tests airports. A StringIO object can use this as an # input source for purposes of testing. TEST_FLIGHTS_SRC = """1,AA1,AA2,0.00,2.00 2,AA2,AA3,4.00,3.50 3,AA3,AA4,7.00,2.00 4,AA4,AA1,2.00,3.00 5,AA1,AA4,0.00,2.00 6,AA1,AA2,12.00,2.00 7,AA5,AA1,13.50,1.00 """ # The scheduled flights for the routes in TEST_ROUTES_SRC. TEST_FLIGHTS_DIR_FOUR_CITIES = [ [1, "AA1", "AA2", 0.00, 2.00], [2, "AA2", "AA3", 4.00, 3.50], [3, "AA3", "AA4", 7.00, 2.00], [4, "AA4", "AA1", 2.00, 3.00], [5, "AA1", "AA4", 0.00, 2.00], [6, "AA1", "AA2", 12.00, 2.00], ] # END: STARTER CODE # OK to remove below here for starter # The first 10 lines of airport.dat from OpenFlights. TEST_AIRPORTS_INPUT_10_LINES = '''1,"Goroka Airport","Goroka","Papua New Guinea","GKA","AYGA",-6.081689834590001,145.391998291,5282,10,"U","Pacific/Port_Moresby","airport","OurAirports" 2,"Madang Airport","Madang","Papua New Guinea","MAG","AYMD",-5.20707988739,145.789001465,20,10,"U","Pacific/Port_Moresby","airport","OurAirports" 3,"Mount Hagen Kagamuga Airport","Mount Hagen","Papua New Guinea","HGU","AYMH",-5.826789855957031,144.29600524902344,5388,10,"U","Pacific/Port_Moresby","airport","OurAirports" 4,"Nadzab Airport","Nadzab","Papua New Guinea","LAE","AYNZ",-6.569803,146.725977,239,10,"U","Pacific/Port_Moresby","airport","OurAirports" 5,"Port Moresby Jacksons International Airport","Port Moresby","Papua New Guinea","POM","AYPY",-9.443380355834961,147.22000122070312,146,10,"U","Pacific/Port_Moresby","airport","OurAirports" 6,"Wewak International Airport","Wewak","Papua New Guinea","WWK","AYWK",-3.58383011818,143.669006348,19,10,"U","Pacific/Port_Moresby","airport","OurAirports" 7,"Narsarsuaq Airport","Narssarssuaq","Greenland","UAK","BGBW",61.1604995728,-45.4259986877,112,-3,"E","America/Godthab","airport","OurAirports" 8,"Godthaab / Nuuk Airport","Godthaab","Greenland","GOH","BGGH",64.19090271,-51.6781005859,283,-3,"E","America/Godthab","airport","OurAirports" 9,"Kangerlussuaq Airport","Sondrestrom","Greenland","SFJ","BGSF",67.0122218992,-50.7116031647,165,-3,"E","America/Godthab","airport","OurAirports" 10,"Thule Air Base","Thule","Greenland","THU","BGTL",76.5311965942,-68.7032012939,251,-4,"E","America/Thule","airport","OurAirports"''' # Used in the test case that reads a 10-line file. TEST_AIRPORTS_OUTPUT_10_LINES = { "GKA": [ "1", "Goroka Airport", "Goroka", "Papua New Guinea", "GKA", "AYGA", "-6.081689834590001", "145.391998291", "5282", "10", "U", "Pacific/Port_Moresby", "airport", "OurAirports", ], "MAG": [ "2", "Madang Airport", "Madang", "Papua New Guinea", "MAG", "AYMD", "-5.20707988739", "145.789001465", "20", "10", "U", "Pacific/Port_Moresby", "airport", "OurAirports", ], "HGU": [ "3", "Mount Hagen Kagamuga Airport", "Mount Hagen", "Papua New Guinea", "HGU", "AYMH", "-5.826789855957031", "144.29600524902344", "5388", "10", "U", "Pacific/Port_Moresby", "airport", "OurAirports", ], "LAE": [ "4", "Nadzab Airport", "Nadzab", "Papua New Guinea", "LAE", "AYNZ", "-6.569803", "146.725977", "239", "10", "U", "Pacific/Port_Moresby", "airport", "OurAirports", ], "POM": [ "5", "Port Moresby Jacksons International Airport", "Port Moresby", "Papua New Guinea", "POM", "AYPY", "-9.443380355834961", "147.22000122070312", "146", "10", "U", "Pacific/Port_Moresby", "airport", "OurAirports", ], "WWK": [ "6", "Wewak International Airport", "Wewak", "Papua New Guinea", "WWK", "AYWK", "-3.58383011818", "143.669006348", "19", "10", "U", "Pacific/Port_Moresby", "airport", "OurAirports", ], "UAK": [ "7", "Narsarsuaq Airport", "Narssarssuaq", "Greenland", "UAK", "BGBW", "61.1604995728", "-45.4259986877", "112", "-3", "E", "America/Godthab", "airport", "OurAirports", ], "GOH": [ "8", "Godthaab / Nuuk Airport", "Godthaab", "Greenland", "GOH", "BGGH", "64.19090271", "-51.6781005859", "283", "-3", "E", "America/Godthab", "airport", "OurAirports", ], "SFJ": [ "9", "Kangerlussuaq Airport", "Sondrestrom", "Greenland", "SFJ", "BGSF", "67.0122218992", "-50.7116031647", "165", "-3", "E", "America/Godthab", "airport", "OurAirports", ], "THU": [ "10", "Thule Air Base", "Thule", "Greenland", "THU", "BGTL", "76.5311965942", "-68.7032012939", "251", "-4", "E", "America/Thule", "airport", "OurAirports", ], } # Two cities, one flight. TEST_ROUTES_DICT_TWO_CITIES = {"AA1": {"AA2"}, "AA2": {"AA1"}} # Three cities. TEST_ROUTES_DICT_THREE_CITIES = {"AA1": {"AA2", "AA3"}, "AA2": {"AA3"}, "AA3": {"AA2"}} TEST_ROUTES_DICT_FIVE_CITIES = { "AA1": {"AA2", "AA4"}, "AA2": {"AA3"}, "AA3": {"AA4", "AA1", "AA2"}, "AA4": {"AA1"}, "AA5": {"AA4"}, } # You can get from the AA5 to anywhere, but not the other way around. # Note that you can't fly anywhere from 'AA6'. TEST_ROUTES_DICT_SIX_CITIES = { "AA2": {"AA3"}, "AA1": {"AA2", "AA4"}, "AA3": {"AA4", "AA1"}, "AA5": {"AA6", "AA4"}, "AA4": {"AA1"}, "AA6": {"AA5"}, } TEST_ROUTES_DICT_FOUR_CITIES_TWO_PATHS = { "AA1": {"AA2", "AA3"}, "AA2": {"AA4"}, "AA3": {"AA4"}, "AA4": {"AA3"}, } TEST_FLIGHTS_DIR_SIX_CITIES = [ [1, "AA1", "AA2", 0.00, 2.00], [2, "AA2", "AA3", 4.00, 3.50], [3, "AA1", "AA4", 4.00, 2.00], [4, "AA3", "AA4", 7.00, 2.00], [5, "AA4", "AA1", 2.00, 3.00], [6, "AA1", "AA4", 0.00, 2.00], [7, "AA1", "AA2", 12.00, 2.00], [8, "AA4", "AA5", 0.00, 2.00], [9, "AA6", "AA1", 23.00, 2.00], ] 

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 Programming Questions!