""" How to Make Cisterns Our friend in the illustration has a large sheet of zinc, measuring (before cutting) eight feet by three feet, and he has cut out square pieces (all of the same size) from the four corners and now proposes to fold up the sides, solder the edges, and make a cistern. But the point that puzzles him is this: Has he cut out those square pieces of the correct size in order that the cistern may hold the greatest possible quantity of water? You see, if you cut them very small you get a very shallow cistern; if you cut them large you get a tall and slender one. It is all a question of finding a way of cutting put these four square pieces exactly the right size. How are we to avoid making them too small or too large? """ import math vol=[] maxvol=0 #the square cutouts can be a maximum of less than 1.5 feet h=range(1,150) #have to be integers but will divide by 100 length=8 width=3 for height in h: height= height/100.0 volume=(length-2*height)*(width-2*height)*height vol.append(volume) if volume>maxvol: maxvol=volume maxdata=[height,maxvol] print 'height %2.2f feet for max volume of %3.2f cubic feet' %(maxdata[0],maxdata[1]) a=3 b=8 print 'From answer in book ' + str(round(( a + b - math.sqrt(a**2 + b**2 - a*b))/6.0,2))+' feet'
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