-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path24.PY
More file actions
70 lines (50 loc) · 1.32 KB
/
24.PY
File metadata and controls
70 lines (50 loc) · 1.32 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
# 24. * *
# ** **
# * * * *
# * * * *
# * ** *
# * ** *
# * * * *
# * * * *
# ** **
# * *
# n=5
# 0 1 2 3 4
# 0 0 1 2 3
# 8 6 4 2 0
# (i-1)*i
n=10
def print_increasing(row):
print("*",end="")
inner_space = 0 if row<=1 else row-1
print(" "*inner_space,end="")
if row!=0:
print("*",end="")
second_inner_space = 2*((n-1)-row)
print(" "*second_inner_space,end="")
print("*",end="")
third_inner_space = 0 if row<=1 else row-1
print(" "*third_inner_space,end="")
if row!=0:
print("*",end="")
def print_decreasing(row):
print("*",end="")
inner_space = n-row-2 if n-row-1>0 else 0
print(" "*inner_space,end="")
if row!=n-1:
print("*",end="")
inner_second_space = row*2
print(" "*inner_second_space,end="")
print("*",end="")
inner_third_space = n-row-2 if n-row-1>0 else 0
print(" "*inner_third_space,end="")
if row!=n-1:
print("*",end="")
print()
def print_pattern():
for row in range(n):
print_increasing(row)
print()
for row in range(n):
print_decreasing(row)
print_pattern()