Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions P/patterns/diamond1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
n=int(input('enter number of layers:'))#horizontal layer

# first n vertical layers
for i in range(n):
print((n-i)*' ',(2*i+1)*'*')

# next n-1 vertical layers
for i in range(n-2,-1,-1):
print((n-i)*' ',(2*i+1)*'*')
5 changes: 5 additions & 0 deletions P/patterns/diamond2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
n=int(input('enter no layers:'))#horizontal layer
for i in range(n+1):
print((2*(n-i)+1)*' ',i*'* ')
for i in range(n-1,-1,-1):
print((2*(n-i)+1)*' ',i*'* ')
24 changes: 24 additions & 0 deletions P/patterns/name_pattern1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'''
Structure
ex: omm
o/p-->
a
b
...
o
oa
ob
...
om
oma
omb
...
omm

'''
name1 = input('your name:')
name = name1.replace(' ', '').lower()
l = len(name)
s = 0
for i in range(l+1):
print(" "*(l-i), name[:i])
7 changes: 7 additions & 0 deletions P/patterns/name_pattern2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name = input("enter name: ")
l = len(name)

for i in range(l):
print(' '*(l-i)**2, name[i])
for i in range(l-1,-1,-1):
print(' '*(l-i)**2, name[i])
11 changes: 11 additions & 0 deletions P/patterns/num_pattern_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""
1
2 2
3 3 3
4 4 4 4
"""

for i in range(1, 10):
for j in range(i):
print(i, end=' ')
print() # for new line
13 changes: 13 additions & 0 deletions P/patterns/num_pattern_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'''
1
1 2
1 2 3
1 2 3 4
'''

for i in range(5):
num = 1
for j in range(i+1):
print(num, end=' ')
num += 1
print() # for new line
12 changes: 12 additions & 0 deletions P/patterns/num_pattern_3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'''
1
2 3
4 5 6
7 8 9 10
'''
num = 1
for i in range(1, 10):
for j in range(i):
print(num, end=' ')
num += 1
print()
12 changes: 12 additions & 0 deletions P/patterns/num_pattern_4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'''
1
2 3 4
5 6 7 8 9
10 11 12 13 14 15 16
'''
num = 1
for i in range(1, 10, 2):
for j in range(i):
print(num, end=' ')
num += 1
print()
7 changes: 7 additions & 0 deletions P/patterns/pyramid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
n = int(input("enter height: "))

for i in range(n):
for j in range(i+1):
print("#", end='')

print()
36 changes: 36 additions & 0 deletions P/patterns/string_ltr_format.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# program to write a string in v shape
while True:
x = input('enter text:')
n = x.replace(' ', '')
l = len(n)
s = 0

if len(x) == 1:
print(0*' ',x)

else:
for i in range(l):
print(i*' ', n[i], (l-2-2*i)*' ', n[l-i-1])
s += 1

# to stop it from continuing after meeting point
if l-2-2*i == 0 or l-2-2*i == 1:
break

if l % 2 != 0: # for words with odd no of letters
print((i+2)*' ', n[l//2])

while True:
rep = input('Try once more?(y/n):')
if rep == 'y':
break
if rep == 'n':
break
if rep != 'y' or 'n':
print('invalid entry')

if rep == 'y':
continue
if rep == 'n':
print('thank you')
break
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ We appreciate the contributions from the following community members:
- [Ezhill Ragesh](https://github.com/ezhillragesh)
- [Brunda Bharadwaj](https://github.com/brundabharadwaj/)
- [Hemanth Singh](https://github.com/Hemanth11011)
- [Omm Satyakam](https://github.com/p-retrover)

---

Expand Down