# Software Sales # This module calculates the discount given based on quantity for software sales # Written by Beth Mela # Last updated April 17, 2015 # Define the software package price and discounts softwarePackagePrice=99 twentyPercent=0.8 thirtyPercent=0.7 fortyPercent=0.6 fiftyPercent=0.5 # Ask user to enter the number of software packages purchased quantity=input('Please enter the number of software packages purchased') print(quantity) # Calculate the discount based on the number of packages purchased and the total price if (quantity>=100): totalPrice=(softwarePackagePrice*fiftyPercent*quantity) print('The discount is 50% and the purchase price after discount is ${:,.2f}.'.format(totalPrice)) elif (quantity>=50): totalPrice=(softwarePackagePrice*fortyPercent*quantity) print('The discount is 40% and the purchase price after discount is ${:,.2f}.'.format(totalPrice)) elif (quantity>=20): totalPrice=(softwarePackagePrice*thirtyPercent*quantity) print('The discount is 30% and the purchase price after discount is ${:,.2f}.'.format(totalPrice)) elif (quantity>=10): totalPrice=(softwarePackagePrice*twentyPercent*quantity) print('The discount is 20% and the purchase price after discount is ${:,.2f}.'.format(totalPrice)) else: totalPrice=(softwarePackagePrice*quantity) print('There is no discount for this quantity and the purchase price is ${:,.2f}.'.format(totalPrice)) # End Module
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