""" 1.”A POST-OFFICE PERPLEXITY. In every business of life we are occasionally perplexed by some ch ance question that for the moment staggers us. I quite pitied a young lady in a branch post-office when a gentleman entered and deposited a crown on the counter with this request: "Please give me some twopenny stamps, six times as many penny stamps, and make up the rest of the money in twopence-halfpenny stamps." For a moment she seemed bewildered, then her brain cleared, and with a smile she handed over stamps in exact fulfilment of the order. How long would it have taken you to think it out? """ #there are a total of 60 pence in a crown #just go from 1 to 7 and see which one satisfies the statement for num in range(1,8): twopenny=num onepenny=6*num twohalfpen=(60-2*twopenny-onepenny)/2.5 if int(twohalfpen)==twohalfpen: print str(twopenny)+' twopenney stamps' print str(onepenny)+ ' onepenny stamps' print str(int(twohalfpen))+ ' twopence-halfpenny stamps'
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