[pythonvis] Box program rewritten after code review

  • From: "Jeffrey Turner" <jturner522@xxxxxxxxx>
  • To: <pythonvis@xxxxxxxxxxxxx>
  • Date: Thu, 22 May 2014 17:04:15 -0400

Hello,

This version of my simple program should be more readable, and uses the for
loop instead of the while loop.

""" This program will draw a box according to width and height specs
provided by the user"""

print "I will now draw a box for you, with pretty plus signs for the
corners,"+"\n"+"dashes for the top and bottom, and bars for the sides."+"\n"

# Get the dimensions from the user

width = input("How wide would you like the box to be?") 

height = input("How high would you like the box to be?")

# Print the top of the box (same as bottom)

print "   +"+"-"*width+"+"

# Print the sides of the box

for i in range(height):
  print "   |"+" "*width+"|"

# Print the bottom of the box

print "   +"+"-"*width+"+" 
print "OK, here is your", width, "by", height, "box."
print "Thank you for doing business with the marvelous JDog."



List web page is 
//www.freelists.org/webpage/pythonvis

To unsubscribe, send email to 
pythonvis-request@xxxxxxxxxxxxx with "unsubscribe" in the Subject field.

Other related posts: