-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClass_Example17.py
More file actions
41 lines (37 loc) · 970 Bytes
/
Class_Example17.py
File metadata and controls
41 lines (37 loc) · 970 Bytes
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
"""
Represent the Graph
"""
class Point:
"""
Class represent the graph along with the point
"""
printed_rep ="*"
def __init__(self, intX, intY):
"""
Initializes the Variables
:param intX: assigns to x
:param intY: assigns to y
"""
self.x = intX
self.y = intY
def graph(self):
"""
Representing the graph
:return: Retuns the graph in the form of string
"""
rows = []
size = max(self.x,self.y)+2
for j in range(size-1):
if (j+1) == self.y:
special_row = str((j+1)%10)+" "*(int(self.x) - 1) + self.printed_rep
rows.append(special_row)
else:
rows.append(str((j+1)%10))
rows.reverse()
x_axis =""
for i in range(size):
x_axis+=str(i%10)
rows.append(x_axis)
return "\n".join(rows)
p1 = Point(3,4)
print(p1.graph())