StartingApples = 40 BagSize = 5 FilledBags = 0 BaggedApples = 0 print "We are starting with {} apples and we're putting {} apples in a bag.".format(StartingApples, BagSize) while (StartingApples - BaggedApples >= BagSize): print "Filling a bag with apples." BaggedApples = BaggedApples + BagSize FilledBags = FilledBags + 1 print "We have filled {} bags of apples, which is a total of {} apples.".format(FilledBags, BaggedApples) print "Starting with {} apples, we have made {} bags of {} and have {} apples left over.".format(StartingApples, FilledBags, BagSize, StartingApples-BaggedApples)
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