-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathGridPrinter.py
More file actions
120 lines (86 loc) · 3.08 KB
/
GridPrinter.py
File metadata and controls
120 lines (86 loc) · 3.08 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#---------------------------------------- #
# Title: GridPrinter.py *In Work*
# Change Log: KCreek, 1/15/2018, Rev New
# KCreek, 1/15/2019, Created File
# KCreek, 1/17/2019, Added Comments and DocString
#---------------------------------------- #
def gridPrint1():
"""
Function that Prints a Grid to the Screen .
This is written to meet the first portion of requirements
for assignment02.
"""
# Print each part of grid line by line.
print('+', '-'*4, '+', '-'*4, '+')
print('|', ' '*4, '|', ' '*4, '|')
print('|', ' '*4, '|', ' '*4, '|')
print('|', ' '*4, '|', ' '*4, '|')
print('|', ' '*4, '|', ' '*4, '|')
print('+', '-'*4, '+', '-'*4, '+')
print('|', ' '*4, '|', ' '*4, '|')
print('|', ' '*4, '|', ' '*4, '|')
print('|', ' '*4, '|', ' '*4, '|')
print('|', ' '*4, '|', ' '*4, '|')
print('+', '-'*4, '+', '-'*4, '+')
print("Presenting: GridPrint1: ")
gridPrint1()
# Part2 of GridPrinter Assignment
def gridPrint2(n):
"""
Prints a Grid sized according to a user provided argument.
This is written to meet the second portion of requirements
for assignment02.
:param n: User Provided Argument to determine Scale for Grid Size
:return: Prints Grid to user, no return value provided
"""
# Define the header and spacer sections to be printed out.
# The space is set by the scale provided by the user.
line1 = '+' + '-'*2*n + '+' + '-'*2*n + '+'
line2 = '|' + ' '*2*n + '|' + ' '*2*n + '|'
# Prints the header to the screen.
print(line1)
# 'While' loop to print the portion of the grid between the header and footer.
i = 0
while i < n:
print(line2)
i +=1
print(line1)
i = 0
while i < n:
print(line2)
i += 1
# Print the footer of the grid, which matches the header
print(line1)
# Call the second grid printer function.
print("Presenting GridPrint2: ")
gridPrint2(10)
# Part 3 of GridPrinter Assignment
def gridPrint3(columns,rows):
"""
Prints a Grid with based on the columns and rows provided by the user.
THis is meant to achieve the third portion of assignment02.
:param columns: Number of Columns desired by user
:param rows: Number or Rows desired by user
:return: Prints a grid to the user based on their inputs"""
# Assign Variables to establish header and spacing lines based on the
# user inputs.
columnHeader = '+ - - - - ' * columns + '+'
rowSpacer = ('| ' * columns + '|')
# While loop to print each row and spacer to the screen. Loop ends when
# The desired amount of rows have been printed to the screen to create a
# body
rowCounter = 0
while rowCounter < rows:
print(columnHeader)
i = 0
while i < 3:
print(rowSpacer)
i += 1
rowCounter += 1
# Print the column header to create a footer by the grid.
print(columnHeader)
# Call the third grid printer function for a variety of rows and columns.
print("Presenting 2 different GridPrint3 Functions: ")
#gridPrint3(3, 3)
gridPrint3(2, 5)
gridPrint3(8, 4)