#Robert Nool III #Discount calculator that shows total after subtracting the discount #Start package = float(99) quantity = input("Please enter how many packages you have bought: ") print quantity print if quantity < 10: print("We're sorry, but the number of packages you have bought does not qualify you for a discount.") discount = 0 print elif quantity < 20: discount = float(0.2) * quantity * package elif quantity < 50: discount = float(0.3) * quantity * package elif quantity < 100: discount = float(0.4) * quantity * package elif quantity >= 100: discount = float(0.5) * quantity * package total = quantity * package - discount print('Your total discount for the {} that you have puchased is ${:,.2f}'.format(quantity,discount)) print print('Your total for this purchase is ${:,.2f}. Thank you for shopping with us'.format(total)) #End
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