20.3k views
6 votes
Write a program to enter the price and display discount percentage using ELSEIF statement. (5) If price>=5000, 20% discount If price>=3000, 15% discount If price>=2000, 10% discount If price>=1000, 5% discount

User Shauri
by
6.2k points

1 Answer

9 votes

Answer:

Step-by-step explanation:

The following code is written in Python and creates a function that takes in the price as a parameter and then returns the discount amount to the user as well as printing it to the screen.

def discountAmount(price):

discount = 0

if price >= 5000:

discount = 20

elif price >= 3000:

discount = 15

elif price >= 2000:

discount = 10

elif price >= 1000:

discount = 5

else:

discount = 0

print("Your total discount is " + str(discount) + "%")

return discount

User Milovan
by
6.7k points