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:

  1. Store the inputted quarter values to the list annualSales (see sample)
  2. Calculate and display the highest quarter
  3. Calculate and display the lowest quarter
  4. Calculate and display the total for the year
  5. Calculate and display the sum of 3 highest quarters
  6. 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
  7. 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!"
  8. 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

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