Skip to content

Commit 572e314

Browse files
committed
adding grid assignment
1 parent 6aaaab7 commit 572e314

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# def grid1():
2+
# print '+ - - - - + - - - - +'
3+
# print '| | |'
4+
# print '| | |'
5+
# print '| | |'
6+
# print '| | |'
7+
# print '+ - - - - + - - - - +'
8+
# print '| | |'
9+
# print '| | |'
10+
# print '| | |'
11+
# print '| | |'
12+
# # print '+ - - - - + - - - - +'
13+
14+
# #grid1()
15+
16+
def printed_grid(n): # This function lets you choose how many boxes, with 2 columns only
17+
s = '+ - - - - + - - - - +' + '\n'
18+
t = ('| | |' + '\n')*4
19+
mid_lines = int((n-2) // 2)
20+
middle = mid_lines*(t + s) + t
21+
22+
if n ==1:
23+
print "Sorry, you need more than 1 box!"
24+
25+
if n%2 != 0:
26+
print "The number of boxes is: ",n,"- 1 =", n-1
27+
n = n - 1
28+
elif n%2==0:
29+
print "The number of boxes is: ", n
30+
31+
if n != 0:
32+
print s, middle, s
33+
34+
# printed_grid(6)
35+
36+
def printed_grids(length): #This function changes the sizes of the boxes , but is always a 2x2 grid
37+
c = int((length-2)//2)
38+
s = ('+' + ' -' * c + ' +' + ' -' * c + ' +') + '\n'
39+
t = ('| ' + ' ' * c + '| ' + ' ' * c + '|') + '\n'
40+
middle = t*c + s + t*c
41+
42+
if (length<4) or (length%2 == 0):
43+
print 'Sorry! The argument should be bigger than 3 and an odd number'
44+
else:
45+
print s,middle,s
46+
47+
# printed_grids(19)
48+
49+
def dynamic_printed_grids(rows, columns, size): #this function lets you choose how many rows, columns, and the size of the boxes
50+
cSize = int((size-2)//2)
51+
s = '+ ' + ((('- ' * cSize ) + '+ ')* columns) + '\n'
52+
t = '| ' + ((' ' * cSize + '| ') * columns) + '\n'
53+
middle = (t*cSize + s) * rows
54+
55+
if size <2:
56+
print "Choose an integer greater than 2"
57+
elif size%2 != 0:
58+
print "The size is: ", size, "- 1 =", size - 1, "and there are", rows, "rows with", columns, "columns"
59+
else:
60+
print "The size is", size, "and there are", rows, "rows with", columns, "columns"
61+
62+
if size >=2:
63+
print s, middle
64+
65+
dynamic_printed_grids(4,3,6)
66+

0 commit comments

Comments
 (0)