Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 96 - 2629_Devagiri_C-7
P. 96

    Program 9 To know the amount of discount based on how much money you spent.
                                            Amount spent                  Discount%

                                           `5000 or more                    20% off
                                           `3000 to `4999                   10% off

                                           `1000 to `2999                   5% off
                                           Less than `1000               No discount

                                     Show the final amount of discount and amount to be paid.

                          Program9.py

                       File  Edit  Format   Run    Options   Window    Help
                       amount = float(input("Enter the total purchase amount: "))
                       if amount >= 5000:
                           discount = 0.20  # 20% discount
                           print("You get a 20% discount.")

                       elif amount >= 3000:
                           discount = 0.10  # 10% discount
                           print("You get a 10% discount.")
                       elif amount >= 1000:
                           discount = 0.05  # 5% discount
                           print("You get a 5% discount.")
                       else:
                           discount = 0     # No discount
                           print("No discount available.")

                       discount_amount=amount*discount
                       print("Discount amount is : ", discount_amount)
                       final_amount = amount - (amount * discount)
                       print("Amount to be paid after discount:", final_amount)

                          Output

                       Enter the total purchase amount: 2500

                       You get a 5% discount.
                       Discount amount is: 125.0
                       Amount to be paid after discount: 2375.0

                       94
                            Premium Edition-VII

| 91 92 93 94 95 96 97 98 99 100 101 |