-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrinting_Number_Pattern.py
126 lines (117 loc) · 2.21 KB
/
Printing_Number_Pattern.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
120
121
122
123
124
125
126
# Program 1:
"""
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
"""
user_input = int(input("Enter the no of rows: "))
for i in range(1,user_input+1):
for j in range(1,i+1):
print(i, end=' ')
print()
# Program 2: --- Pyramid Patten of Numbers
"""
1
12
123
1234
12345
"""
user_input = int(input("Enter the no of rows: "))
for i in range(1,user_input+1):
for j in range(1,i+1):
print(j, end= '')
print()
# Program 3: --- Inverted Pyramid Pattern of Numbers
"""
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1
"""
user_input = int(input("Enter the no of rows: "))
for i in range(user_input,0,-1):
for j in range(1,i+1):
print(i, end=' ')
print()
# Program 4: ---Inverted Pyramid Pattern with same digit
"""
5 5 5 5 5
5 5 5 5
5 5 5
5 5
5
"""
user_input = int(input("Enter the no of rows: "))
for i in range(user_input,0,-1):
for j in range(1, i+1):
print(user_input, end=' ')
print()
# Program 5: ---Inverted half pyramid pattern with number
"""
0 1 2 3 4 5
0 1 2 3 4
0 1 2 3
0 1 2
0 1
"""
user_input = int(input("Enter the no of rows: "))
for i in range(user_input,1,-1):
for j in range(0,i):
print(j, end='')
print()
# Program 6: ---Printing alternate numbers
"""
1
3 3
5 5 5
7 7 7 7
9 9 9 9 9
"""
user_input = int(input("Enter the no of rows: "))
for i in range(1,user_input+1):
for j in range(1, i+1):
print((i*2-1), end='')
print()
# Program 7: ---Printing reverse number pattern
"""
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1
"""
user_input = int(input("Enter the no of rows: "))
for i in range(user_input, 0,-1):
for j in range(1, i+1):
print(i, end='')
print()
# Program 8: ---Printing reverse number pattern
"""
1
2 1
3 2 1
4 3 2 1
5 4 3 2 1
"""
user_input = int(input("Enter the no of rows: "))
for i in range(1,user_input+1):
for j in range(i,0,-1):
print(j, end='')
print()
# Program 9: ---Printing reverse number pattern
"""
5 4 3 2 1
4 3 2 1
3 2 1
2 1
1
"""
user_input = int(input("Enter the no of rows: "))
for i in range(user_input,0,-1):
for j in range(i,0,-1):
print(j, end='')
print()