-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathgrid.py
More file actions
93 lines (59 loc) · 2.24 KB
/
grid.py
File metadata and controls
93 lines (59 loc) · 2.24 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
"""This module contains a code example related to
Think Python, 2nd Edition
by Allen Downey
http://thinkpython2.com
Copyright 2015 Allen Downey
License: http://creativecommons.org/licenses/by/4.0/
"""
"""Create variables for the addition and subtraction operators
and print them in the order and number of times in which they appear on a line."""
def operators():
add = "+ "
sub = "- " * 4
print(add,sub,add,sub,add)
"""Create a function that prints the straight beams and adds the appropriate amount of space between them"""
def straight_beams():
#You multiply the straight line-space convention by n-1 columns to get the 1st and middle columns and add the final column to complete the row"
print(("|" + " " * 11 ) * 2 + "|")
"""Create a function that would repeat the straight_beams function 4 times when passed as an argument"""
def do_four_times(func):
func()
func()
func()
func()
"""The final function that arranges the previous functions in the order that creates the grid"""
def grid_maker():
operators()
do_four_times(straight_beams)
operators()
do_four_times(straight_beams)
operators()
grid_maker()
"""For the 4x4 grid"""
"""Create variables for the addition and subtraction operators
and print them in the order and number of times in which they appear on a line."""
def operators():
add = "+ "
sub = "- " * 4
print(add,sub,add,sub,add,sub,add)
"""Create a function that prints the straight beams and adds the appropriate amount of space between them"""
def straight_beams():
#You multiply the straight line-space convention by n-1 columns to get the 1st and middle columns and add the final column to complete the row"
print(("|" + " " * 11 ) * 3 + "|")
"""Create a function that would repeat the straight_beams function 4 times when passed as an argument"""
def do_four_times(func):
func()
func()
func()
func()
"""The final function that arranges the previous functions in the order that creates the grid"""
print("Here's your 4x4 grid below")
def grid_maker():
operators()
do_four_times(straight_beams)
operators()
do_four_times(straight_beams)
operators()
do_four_times(straight_beams)
operators()
grid_maker()