__author__ = 'wadman.co.nz' def cost_of_shirt(shirts): x = shirts cost = 0 if x <= 5: cost += (17.45 * x) elif x == 6: cost += (17.15 * x) elif x == 7: cost += (16.85 * x) elif x == 8: cost += (16.55 * x) elif x == 9: cost += (16.25 * x) elif x >= 10 and x < 20: cost += (16.15 * x) elif x >= 20 and x < 30: cost += (15.55 * x) else: return "Sorry, there has been an error" return "You will need to sell a shirt for more than %s to make a profit" % (((cost * 1.125) + 35) / x) no_shirts = (raw_input("How many shirts are you wanting to print?:")) while no_shirts.isdigit() == False: print "Sorry, you have not entered a valid number." no_shirts = raw_input("Please enter a number greater than 0:") no_shirts = int(no_shirts) while no_shirts < 1 or no_shirts > 29: print "Please enter a number between 1 and 29:" no_shirts = raw_input("Please enter a number greater than 0:") no_shirts = int(no_shirts) print cost_of_shirt(no_shirts)
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