-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchapter3.py
77 lines (64 loc) · 1.56 KB
/
chapter3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
def do_twice(f):
f()
f()
def do_three(f):
f()
f()
f()
def do_four(f):
do_twice(f)
do_twice(f)
#prints the horizontal part of the cell (+ - - - - )
def cell_row():
print(' + ' + ' - ' * 4, end='')
#continues the horizontal part of the cell (+ - - - - +)
def another_cell_row():
print(' + ' + ' - ' * 4, end=' +')
#this is (+ - - - - + - - - -+)
def row_for_two():
cell_row()
another_cell_row()
#this is (+ - - - - + - - - -+ - - - - + - - - -+)
def row_for_four():
do_three(cell_row)
another_cell_row()
#this is (| )
def single_column():
print(' | ' + ' ' * 4, end='')
#this is (| | |)
def two_columns():
print('')
do_three(single_column)
#this is (| | | | |)
def four_columns():
do_three(single_column)
do_twice(single_column)
print('')
#here handles the top 2 boxes
def two_cell_boxes():
row_for_two()
do_four(two_columns)
print('')
#here prints the 4 boxes, 2 above, 2 below)
def four_cell_boxes():
do_twice(two_cell_boxes)
row_for_two()
#here is to print 4 boxes on a row
def four_cell_rows():
row_for_four()
print('')
do_four(four_columns)
#here is to print 4x2 boxes
def eight_cell_boxes():
do_twice(four_cell_rows)
row_for_four()
#here is to complete the 4x4 boxes
def sixteen_cell_boxes():
do_four(four_cell_rows)
row_for_four()
print('this is a 2x2 box')
four_cell_boxes()
print('')
print('this is a 4x4 box')
print('')
sixteen_cell_boxes()