Question: Question 1 : Analyzing Flight Data for an Aviation Company Objective: The objective of this assignment is to introduce intermediate Python programming concepts such as
Question : Analyzing Flight Data for an Aviation Company
Objective: The objective of this assignment is to introduce intermediate Python programming concepts such as strings, functions, and lists. By the end of this assignment, you will be able to manipulate strings, create and use functions, and work with lists to solve a more complex problem related to analyzing flight data for an aviation company.
Scenario: You are a data analyst for an aviation company. The company operates multiple flights, and you need to analyze the flight data to provide insights. The program should be able to calculate the average mean median, and mode of flight durations, identify the flight with the longest duration, and categorize flights based on their duration.
Problem Statement: Write a Python program that:
Takes user input for a list of flight numbers and their corresponding durations in minutes
Calculates the average mean flight duration.
Calculates the median flight duration.
Calculates the mode of the flight durations.
Identifies the flight with the longest duration.
Categorizes flights into "Shorthaul" less than hours "Mediumhaul" to hours and "Longhaul" more than hours
Prints the results in a formatted string.
Assumptions:
The user will provide the list of flight numbers and their corresponding durations.
Each flight has only one duration associated with it
The list will contain at least one flight.
Instructions: Optional to follow instructions!
Define a function calculatemean that takes a list of durations and returns the average mean duration.
Define a function calculatemedian that takes a list of durations and returns the median duration.
Define a function calculatemode that takes a list of durations and returns the mode duration. If there is no mode, print the entire list of durations.
Define a function findlongestflight that takes a list of flight numbers and their corresponding durations, and returns the flight number with the longest duration. In case there are multiple flights with the same longest duration, return just the first longest flight
Define a function categorizeflights that takes a list of flight numbers and their corresponding durations, and returns a dictionary categorizing flights into "Shorthaul", "Mediumhaul", and "Longhaul".
Use user input to create the list of flight numbers and durations.
Call the defined functions to calculate the mean, median, mode, longest flight, and categorize flights, and print the results.
Deliverables:
A Python script that includes the defined functions and the main program logic.
The script should prompt the user for input and print the average mean duration, median duration, mode duration, the flight with the longest duration, and the categorized flights in a formatted string.
Page of
Sample Output :
Enter the number of flights:
Enter flight number: CX
Enter duration for flight CXin minutes:
Enter flight number: CX
Enter duration for flight CXin minutes:
Enter flight number: CX
Enter duration for flight CXin minutes:
Enter flight number: CX
Enter duration for flight CXin minutes:
Enter flight number: CX
Enter duration for flight CXin minutes:
Mean duration: minutes
Median duration: minutes
Mode duration:
minutes
Longest flight: CX
Categorized flights:
Shorthaul: CXCX
Mediumhaul: CXCX
Longhaul: CX
Sample Output :
Enter the number of flights:
Enter flight number: DXB
Enter duration for flight DXBin minutes:
Enter flight number: DXB
Enter duration for flight DXBin minutes:
Enter flight number: DXB
Enter duration for flight DXBin minutes:
Enter flight number: DXB
Enter duration for flight DXBin minutes:
Enter flight number: DXB
Enter duration for flight DXBin minutes:
Mean duration: minutes
Median duration: minutes
Mode duration: minutes
Longest flight: DXB
Categorized flights:
Shorthaul: DXBDXB
Mediumhaul: DXBDXB
Longhaul: DXB
Page of
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
