Objective

Given a collection of prices of some items, output a table showing each price, the discount offered, and the price after the discount.

Difficulty

Very easy

Description

You are given the following list of tuples modeling some details of a couple of items in a shopping store:

items = [(50, 30), (85, 10), (300, 15), (20, 5)]

Each tuple consists of two elements: the first is the actual price of an item in the store and the second is its discount, given as a percentage value.

Your task is to take this list and output a table showing each item's actual price, its discount and price after discount on a separate row.

Each column of this table should be of length 20 and the text within it should be left-aligned.

The headings of the table should be 'Price', 'Discount' and 'Price after discount, respectively. After the table's header, leave a blank line.

Furthermore, wherever prices are output, they should be to 2 decimal places and begin with the $ sign. For instance, if the price is 30, it should be output as '$30.00'; if the price is 50.789, it should be output as '$50.79'; and so on and so forth.

The discount should be output with a % sign at its end. For instance, if the discount is 20, the output should be '20%'.

Shown below is the required output:

Price Discount Price after discount $50.00 30% $35.00 $85.00 10% $76.50 $300.00 15% $255.00 $20.00 5% $19.00

Hints