A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Python | Calculate discount based on the sale amount
Q:

Python | Calculate discount based on the sale amount

0

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%

 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program:

# 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

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now