def bounding_box(h, w): dim = (h, w) area = h*w x ="h: %s, w: %d" % (h, w) y ="area: %s" % (area) if len(x) < (dim[1] -3) and h >= 4: print ("*" * width) print (("*" + (" " * (width-2)) + "*\n") * (height/2 - 2)), print "*" + " " + x + (" " * (int(width - len(x) - 3))) + "*" print "*" + " " + y + (" " * (int(width - len(y) - 3))) + "*" print (("*" + (" " * (width-2)) + "*\n") * (height/2 - 2 + height%2)), print ("*" * width) else: print ("*" * width) print (("*" + (" " * (width-2)) + "*\n") * (height -3)) + ("*" +(" " * (width-2) + "*")) print ("*" * width) print x print y height = int(raw_input('Height==> ')) print height width = int(raw_input('Width==> ')) print width bounding_box(height, width)
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