67.3k views
11 votes
A shop will give discount of 10% if the cost of purchased quantity is more than 1000. Ask user for quantity suppose, one unit will cost 100. Judge and print total cost for user.

User Kalle
by
3.8k points

1 Answer

5 votes

Answer:

The program in Python is as follows:

qty = int(input("Quantity: "))

price = 100 * qty

if qty >1000:

price = (100 - 0.10 * 100) * qty

print("Cost: "+str(price))

Step-by-step explanation:

This prompts the user for the quantity

qty = int(input("Quantity: "))

This calculates the price or cost, without discount

price = 100 * qty

This checks if the quantity is greater than 1000

if qty >1000:

If yes, this calculates the price or cost, after discount

price = (100 - 0.10 * 100) * qty

This prints the calculated cost

print("Cost: "+str(price))

User Kyle Walsh
by
4.2k points