livepython.net

34. Python Program to Print a Shopping Bill with Variables

HardTypes

Overview

Put the whole chapter together: variables, calculations and types, in one small program.

Problem Statement

A shop sells pens at 10 each and notebooks at 45 each. Sunny buys 3 pens and 2 notebooks and pays by card.

Store every price, quantity and the payment method in variables, calculate the totals with those variables (don't type the answers yourself), and print this bill. The columns are separated by tabs (\t):

Item Qty Total
Pen 3 30
Notebook 2 90
Grand total 120
Paid by card: True

Input

No input is required for this question.

Output

The 5 lines above, with a tab between the columns and two tabs before 120.

Learn this firstChapter 4 · Python Variable Types: str, int, float and bool
solution.py
# write your code here

EXPECTED OUTPUT

1Item Qty Total
2Pen 3 30
3Notebook 2 90
4Grand total 120
5Paid by card: True

YOUR OUTPUT

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