# Week 3 Ex 7: Software Sales - This program calculates discounts based on the quantity of software packages purchased. #It calculates the discount in $. #Finally, it shows the total amount for the purchase after discount is applied. # Written by Greg Lamb. # Last modified on 04/11/2015 SWPackage= float(99.00) Discount=0 TotalPurchase=0 Qty=input('Enter the quantity of software Packages you wish to buy: ') print Qty if (Qty>=10 and Qty<=19): Discount=(Qty * SWPackage * float(0.2)) elif (Qty>=20 and Qty<=49): Discount=(Qty * SWPackage * float(0.3)) elif (Qty>=50 and Qty<=99): Discount=(Qty * SWPackage * float(0.4)) elif (Qty>=100): Discount=(Qty * SWPackage * float(0.5)) else: Discount=(Qty * SWPackage * float(0.0)) TotalPurchase=(Qty * SWPackage - Discount) print("You bought {} software packages at a discount of ${:,.2f} Which will cost you a total of ${:,.2f}".format(Qty,Discount,TotalPurchase))
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question