×

Python Tutorial

Python Basics

Python I/O

Python Operators

Python Conditions & Controls

Python Functions

Python Strings

Python Modules

Python Lists

Python OOPs

Python Arrays

Python Dictionary

Python Sets

Python Tuples

Python Exception Handling

Python NumPy

Python Pandas

Python File Handling

Python WebSocket

Python GUI Programming

Python Image Processing

Python Miscellaneous

Python Practice

Python Programs

Python | Calculate discount based on the sale amount

Python | if elif example: Here, we are implementing a program, it will input sale amount and calculate the discount based on input amount.
Submitted by Pankaj Singh, on September 29, 2018

Problem statement

Input same amount and calculate discount based on the amount and given discount rate in Python.

The discount rates are:

    Amount          Discount
    0-5000          5%
    5000-15000      12%
    15000-25000     20%
    above 25000     30%

Python program to calculate discount based on the sale amount

# input sale amount
amt = int(input("Enter Sale Amount: "))

# checking conditions and calculating discount
if(amt>0):
    if amt<=5000:
       disc = amt*0.05
    elif amt<=15000:
        disc=amt*0.12
    elif amt<=25000:
        disc=0.2 * amt
    else:
         disc=0.3 * amt

    print("Discount : ",disc)
    print("Net Pay  : ",amt-disc)
else:
    print("Invalid Amount")

Output

Enter Sale Amount: 30000
Discount :  9000.0
Net Pay  :  21000.0

To understand the above example, you should have the knowledge of the following Python topics:

Python Basic Programs »

Advertisement
Advertisement

Related Programs

Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.