-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShapeImage.py
119 lines (100 loc) · 2.42 KB
/
ShapeImage.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
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
#Right Triangle
x = int(raw_input("Rows- "))
x = x + 1
for i in range (0,x):
for j in range (0,i):
print "X",
print ""
#Square
x = int(raw_input("Rows- "))
y = int(raw_input("Columns- "))
for i in range (0,x):
for j in range (0,y):
print "X",
print ""
#Upside Down Right Triangle
x = int(raw_input("Rows- "))
for i in range (x, 0, -1):
for j in range(0,i):
print "X",
print ""
#Empty Square
Rows = int(raw_input("Rows- "))
Columns = int(raw_input("Columns- "))
for i in range(Rows - 1):
if i == 0:
for j in range(Columns):
print "X",
print " "
if i == Rows - 2:
for l in range(Columns):
print "X",
print " "
else:
for m in range(Columns - 1):
if m == 0:
print "X",
if m == Columns - 2:
print "X"
else:
print " ",
#Upside Down Isosceles Triangle
x = int(raw_input("Rows- ")) + 1
a = -1 + (2 * x)
s = " "
for i in range(0,x):
a = a - 2
s = s + " "
print s,
for j in range(0,a):
print "X",
print ""
#Upside Down Empty Isosceles Triangle
import sys
x = int(raw_input("Rows- "))
a = -1 + (2 * x)
s = ""
b = 1 + (x - 1) * 2
a_1 = x - 1
for i in range(0,x):
if i == 0:
for j in range(0,b):
sys.stdout.write('X'),
print ""
elif i == a_1:
s = s + " "
print s + "X"
else:
a = a - 2
print s,
print "X",
for j in range(0,a-2):
sys.stdout.write(' '),
sys.stdout.write('X'),
print ""
s = s + " "
#Pine Tree
userInput = raw_input("Rows- ")
spaces = int(userInput) * 2 / 3 - 1
numberOfX = 1
trunk = int(userInput) * 2 / 3
trunkSize = int(userInput) / 2
trunkSpaces = int(userInput) / 3
if int(userInput) == 5:
trunkSize = trunkSize + 1
for i in range(int(userInput)):
if i < int(trunk):
for k in range(spaces):
print " ",
for j in range(numberOfX):
print "X",
numberOfX = int(numberOfX) + 2
spaces = int(spaces) - 1
print " "
else:
for l in range(trunkSpaces):
print " ",
for m in range(trunkSize):
print "X",
print " "
#X