Question
Python 3: Design an algorithm and create a program that will take the amount reported for four quarters and do the following: Store the inputted
Python 3: Design an algorithm and create a program that will take the amount reported for four quarters and do the following:
- Store the inputted quarter values to the list annualSales (see sample)
- Calculate and display the highest quarter
- Calculate and display the lowest quarter
- Calculate and display the total for the year
- Calculate and display the sum of 3 highest quarters
- Calculate the percent difference:
- The percent difference is calculated by taking the absolute value of the "sum of 3 highest quarters" and the "total for the year", divided by the "total for the year", and multiplied by 100
- percentDiff = | (sum of 3 highest quarters) - (total for the year) | / (total for the year) * 100
- When calculating this value, you use must the absolute value method found in the math library
- Use a dictionary to select and output a message depending on the value of percentDiff:
- A percentDiff between 20 to 39% use message1 - "Consistent quarters!"
- A percentDiff between 10 to 19% use message2 - "Work harder next year!"
- A percentDiff between 0 to 9% use message3 - "Lowest quarter was an anomaly!"
- Use a list method to sort the list of quarters from lowest to highest values.
Sample Output:
Please enter 1st quarter amount: 500000 Please enter 2nd quarter amount: 125351.2536 Please enter 3rd quarter amount: 3750656.331 Please enter 4th quarter amount: 475258
You entered: [500000, 125351.2536, 3750656.331, 475258] The highest quarter was: 3750656.33 The lowest quarter was: 125351.25 The total for the year was: 4851265.58 Sum of the 3 highest quarters: 4725914.33 The percent diff: 2.58% - The lowest quarter was an anomaly!
Quarters sorted: [125351.2536, 475258, 500000, 3750656.331]
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