#Program calculates amount of discount given based on quantity of units purchased # Written by Tuan Nguyen # 4/16/15 packagePrice = 99 packagesPurchased = input("Enter amount of packages purchased.") if packagesPurchased < 10: #setting discount percentage based on number of packages purchased discountPercent = 0 elif packagesPurchased > 9 and packagesPurchased < 20: discountPercent = .2 elif packagesPurchased > 19 and packagesPurchased < 50: discountPercent = .3 elif packagesPurchased > 49 and packagesPurchased < 100: discountPercent = .4 else: discountPercent = .5 originalAmount = packagesPurchased * packagePrice #calculating original price discountAmount = originalAmount * discountPercent #calculating discount amount finalAmount = originalAmount - discountAmount #price minus discount (if any) print ("Your final amount is ${:,.2f} after a ${:,.2f} discount.".format(finalAmount,discountAmount))
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