0% found this document useful (0 votes)
8 views4 pages

Pattern Programs Part 9

The document contains Python code snippets for generating various star patterns based on user input. It includes patterns such as triangles, diamonds, and rectangles created using loops and print statements. The code is attributed to Leela Soft and author Madhu.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views4 pages

Pattern Programs Part 9

The document contains Python code snippets for generating various star patterns based on user input. It includes patterns such as triangles, diamonds, and rectangles created using loops and print statements. The code is attributed to Leela Soft and author Madhu.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Leela Soft Python Patterns Madhu

print("1", end=" ")


else:
print("0", end=" ")
print()

'''
Pattern-98:
*
* *
* * *
* * * *
* * * * *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
* * * * * * * * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
* * * * * * * * *
* * * * * * * * * *
* * * * * * * * * * *
* * * * * * * * * * * *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
'''

num = int(input("Enter a number:"))


for i in range(1, num + 1):
print(" "*(2 * num - i + 3), end="")
for j in range(1, i + 1):
print("*", end=" ")
print()
for i in range(1, num + 3):
print(" "*(2 * num - i + 1), end="")

[Link] Cell: 78 42 66 47 66
Leela Soft Python Patterns Madhu

for j in range(-1, i + 1):


print("*", end=" ")
print()
for i in range(1, num + 5):
print(" "*(2 * num - i), end="")
for j in range(-2, i + 1):
print("*", end=" ")
print()
for i in range(1, num + 3):
print(" "*((2 * num)), end="")
print("* "*3)

'''
Pattern-99:
*
* *
* * *
* * * *
* * * * *
* *
* * * *
* * * * * *
* * * * * * * *
* * * * * * * * * *
'''

num = int(input("Enter a number"))


for i in range(1, num + 1):
print(" "*(2 * num - i), end="")
for j in range(1, i + 1):
print("*", end=" ")
print()
for i in range(1, num + 1):
print(" "*(num - i), end="")
for j in range(1, i + 1):
print("*", end=" ")
print(" "*(num - i), end="")
for k in range(1, i + 1):
print("*", end=" ")
print()

'''
Pattern-100:
**
**

[Link] Cell: 78 42 66 47 66
Leela Soft Python Patterns Madhu

****
****
******
******
********
********
**********
**********
'''

n = int(input("Enter a number"))
for i in range(1, 2 * n + 1):
if i % 2 == 0:
print("*"*i, end=" ")
else:
print("*"*(i + 1), end=" ")
print()

'''
Pattern-101:
*
* *
* * *
* * * *
* * * * *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
* * * * * * * * *
* * *
* * *
* * *
* * *
* * *
'''

n = int(input("Enter a number:"))
for a in range(1, n + 1, 2):
for i in range(1, n + 1):

[Link] Cell: 78 42 66 47 66
Leela Soft Python Patterns Madhu

print(" "*(2 * n - i - a), end="")


for j in range(1, i + a):
print("*", end=" ")
print()
for b in range(1, n + 1):
print(" "*(n - 2), end="")
print("* "*3)

[Link] Cell: 78 42 66 47 66

You might also like