#Josh Roybal #CIS 122 #Chapter 4, Programming Exercise #7 quantity = 0 total = 0 price = 99 discountTotal = 0 discountOne = 0.8 #20% off discountTwo = 0.7 #30% off discountThree = 0.6 #40% off discountFour = 0.5 #50% off quantity = input("Please enter the number of packages purchased: ") print("\n") if quantity < 10: total = quantity * price discountTotal = quantity * price - total print 'The price for', quantity, 'items is $', total, '\n' print 'You saved $', discountTotal, ', purchase 10 or more for a discount!' elif quantity >= 10 and quantity < 20: total = quantity * price * discountOne discountTotal = quantity * price - total print 'The price for', quantity, 'items is $', total, '\n' print 'You saved $', discountTotal, ', a total of 20% off!' elif quantity >= 20 and quantity < 50: total = quantity * price * discountTwo discountTotal = quantity * price - total print 'The price for', quantity, 'items is $', total, '\n' print 'You saved $', discountTotal, ', a total of 30% off!' elif quantity >= 50 and quantity < 100: total = quantity * price * discountThree discountTotal = quantity * price - total print 'The price for', quantity, 'items is $', total, '\n' print 'You saved $', discountTotal, ', a total of 40% off!' else: total = quantity * price * discountFour discountTotal = quantity * price - total print 'The price for', quantity, 'items is $', total, '\n' print 'You saved $', discountTotal, ', a total of 50% off!'
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