# CSE 142 Autumn 2007, Marty Stepp # # This program prints many lines and boxes of stars in a loop. # This version uses for loops and also shows an advanced concept: # The String data type. (hasn't been covered in lecture yet) # # the original program's output (lines and boxes of stars) # Draws a box of stars with the given dimensions. def draw_box(width, height, c="*"): print c*width + "\n" + (c + " "*(width - 2) + c + "\n")*(height-2) + c*width draw_box(5, 4, "#") draw_box(10, 6, ".") print # additional output: 3x6, 4x8, 5x10, ..., 10x20 boxes for i in range(3,11): draw_box(2 * i, i, "$")