livepython.net

58. Python Program to Make a Shopping Receipt from Input

HardInteractive

Overview

Put the whole chapter together: several inputs of different types, calculations, and neat output.

Problem Statement

Read an item name, its price (may have decimals) and a quantity (whole number), one per line. Print a receipt with the subtotal, a 10 per cent tax and the total, all with two decimal places. For example, for Pen, 10.5 and 3, print:

Item: Pen
Price: 10.50 x 3
Subtotal: 31.50
Tax (10%): 3.15
Total: 34.65

Use input() with no prompt text: the tests type the input for you, and a prompt would end up in your output.

Input

One value per line, in this order. Example:

Pen
10.5
3

Output

The output for that example:

Item: Pen
Price: 10.50 x 3
Subtotal: 31.50
Tax (10%): 3.15
Total: 34.65

The tests try 3 different inputs.

Learn this firstChapter 7 · Build Small Interactive Python Programs
solution.py
# write your code here

EXPECTED OUTPUT

1Item: Pen
2Price: 10.50 x 3
3Subtotal: 31.50
4Tax (10%): 3.15
5Total: 34.65

YOUR OUTPUT

Press Run to see your output here. Lines are compared with the expected output.