Quick links
Latest articles
Internship
Members
New...
Algorithms
Discrete Mathematics
Big data
Languages
C
C++
C++ STL
Java
Data Structure
C#.Net
Android
Kotlin
SQL
Web
PHP
Python
JavaScript
CSS
Ajax
Node.js
Web prog.
Programs
C
C++
DS
Java
C#
Python
Aptitude
C
C++
Java
DBMS
Interview
C
Embedded C
Java
SEO
HR
CS Subjects
CS Basics
O.S.
Networks
DBMS
Embedded Systems
Cloud Computing
Machine learning
CS Organizations
Linux
DOS
More...
Articles
Puzzles
News/Updates

Home » Python programs

Python | Calculate discount based on the sale amount using Nested if else



Python | Nested if else example: Here, we are implementing a program, it will input sale amount and calculate the discount based on input amount using nested if else.
Submitted by Pankaj Singh, on October 04, 2018

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%

Program:

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

# conditions to check amount and get discount
if(amt>0):
    if amt<=5000:
       disc = amt*0.05
    else:
        if amt<=15000:
            disc=amt*0.12
        else:
            if amt<=25000:
                disc=0.2 * amt
            else:
                disc=0.3 * amt
    
    # printing discount and net payable amount 
    print("Discount : ",disc)
    print("Net Pay  : ",amt-disc)
else:
    print("Invalid Amount")

Output

Enter Sale Amount: 22000
Discount :  4400.0
Net Pay  :  17600.0





Quick links:
C FAQ(s) C Advance programs C/C++ Tips & Tricks Puzzles JavaScript CSS Python Linux Commands PHP Android Articles More...

Featured post:
Introduction to Linux (Its modes, Safety, Most popular Applications)
Linux Best Distribution Software (Distros) of 2018

Was this page helpful? Please share with your friends...

Are you a blogger? Join our Blogging forum.

Comments and Discussions



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com (2015-2018), Some rights reserved.