#softeware sales QuantityPurchased = raw_input('Enter the number of packages purchased') QuantityPurchased = float(QuantityPurchased) UnitPrice=99 Discount = "" if(QuantityPurchased < 10): Discount=float(0) elif(QuantityPurchased >= 10 and QuantityPurchased <=19): Discount =float(.2) elif(QuantityPurchased >= 20 and QuantityPurchased <=49): Discount =float(.3) elif(QuantityPurchased >=50 and QuantityPurchased <=99): Discount =float(.4) elif(QuantityPurchased >=100): Discount=float(.5) Total = (UnitPrice * QuantityPurchased - (Discount*QuantityPurchased*UnitPrice)) TotalDiscount = Discount*QuantityPurchased*UnitPrice print('Your Total discount on {0} Packages is ${1:,.2f}, and your total cost is ${2:,.2f}'.format(QuantityPurchased,TotalDiscount,Total))
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