Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Records And Database Management

Authors: Jeffrey R Stewart Ed D, Judith S Greene, Judith A Hickey

4th Edition

0070614741, 9780070614741

More Books

Students also viewed these Databases questions

Question

What strategies do you currently use for reading and studying?

Answered: 1 week ago

Question

Derive expressions for the rates of forward and reverse reactions?

Answered: 1 week ago

Question

Write an expression for half-life and explain it with a diagram.

Answered: 1 week ago

Question

What do you mean by underwriting of shares ?

Answered: 1 week ago

Question

Define "Rights Issue".

Answered: 1 week ago

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago