Question
I need help in this program. Please do it correctly and follow the output . I put the stating code as well with the output
I need help in this program. Please do it correctly and follow the output . I put the stating code as well with the output
## Your function should above this line. Do not change anything below this line
airports = { "Los Angeles":["Boston","New York","Denver","Salt Lake City"],
"Billings":["Denver","Seattle","Salt Lake City"],
"Bozeman":["Denver","Billings"],
"Denver":["Los Angeles","Bozeman","New York","Boston","Atlanta"],
"Atlanta":["Dallas"] }
start = input("What is your starting airport?")
destination = input("What airport is your destination?")
calculate_number_of_flights(start,destination,airports)
Consider a dictionary that contains information about an airport and the other airports it can fly to. The keys of the dictionary (string) represent a single airport, and the values (list of strings) are the other airports that it has flights to For example, consider the following dictionary: airports = Los Angeles":["Boston. New York Denyer Salt "Salt Lake City"), "Billings":["Denver" Seattle Salt Lake City"), "Bozeman": I "Denver", "Billings"], "Denver""Los Angeles""Bozeman" "New York". "Boston" "Atlanta"), "Atlanta. "Dallas"] } This would mean that Los Angeles has flights to Boston, New York, Denver, and Salt Lake City. Billings has flights to Denver, Seattle, and Salt Lake City. Bozeman has flights to Denver and Billings, and so on and so forth A connecting flight is a pitstor between the starting airport and the destination. For example, if someone in Billings wanted to fly to Los Angeles, they would have to make a pit stop in Denver, because Billings does not have any flights directly to Los Angeles, but Denver does. (Billings -> Denver -> Los Angeles) Using the provided code below, write a function that takes in an input starting airport (Ex Billings) and an input desired destination airport (Ex. Los Angeles). Your function should calculate the number of flights it would take to go from the starting airport to the destination airport. If there is not a direct flight to go from the start to destination, then your function should check if you can go from the starting airport to destination airport with one connecting flight. If the starting airport cannot travel to destination airport directly and cannot travel to the destination airport through one connecting flight, then a different message should be printed out (see sample outputs) WWW ## Your function should above this line. Do not change anything below this line airports Los Angeles":["Boston" York". Denver Salt Lake City"], "Billings "Denver' Seattle Salt Lake City"], "Bozeman""Denver Billings"], "Denver" "Los Angeles "Bozeman". New York". "Boston","Atlanta"), "Atlanta":["Dallas"] } start = input.("What is your starting airport?") destination = input. "What airport is your destination?") calculate number of flights (stant destination airports) Below are 4 different example outputs that may be produced What is your starting airport?Billings What airport is your destination?Denver To go from Billings to Denver will take 1 flights (Billings has a direct flight to Denver, so it only takes 1 flight) What is your starting airport?Bozeman What airport is your destination?Boston To go from Bozeman to Boston will take 2 flights (Bozeman does not have a direct flight to Denver, but it can reach Boston through a connecting flight in Denver (Bozeman -> Denver -> Boston), so it takes 2 flights.) Page 5 What is your starting airport?Bozeman What airport is your destination?Dallas Bozeman does not go to Dallas or it would take more than two flights (Bozeman does not have a direct flight to Dallas, and cannot reach Dallas through one connecting flight, so the following message should get printed out) What is your starting airport?Bozeman What airport is your destination? Chicago Bozeman does not go to Chicago or it would take more than two flights (Bozeman does not have a direct flight to Chicogo, and connot reach Chicago through one connecting flight, so the following message should get printed out) The only possible outcomes are 1 flight, 2 flights, or not possible. If you can't solve the entire problem, remember to try to get as much done as you can! If you cant get the connecting flights to work, at least try to get your function to correctly identify the cases where it only takes 1 flightStep 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