-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPatterns.py
More file actions
37 lines (28 loc) · 747 Bytes
/
Copy pathPatterns.py
File metadata and controls
37 lines (28 loc) · 747 Bytes
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
# Pattern Printing using Match-Case (Python 3.10+)
choice = int(input("""
Choose Pattern:
1. Square
2. Right Triangle
3. Pyramid
4. Inverted Triangle
Enter Choice: """))
rows = int(input("Enter Number of Rows: "))
match choice:
case 1:
print("\nSquare Pattern")
for i in range(rows):
print("* " * rows)
case 2:
print("\nRight Triangle")
for i in range(1, rows + 1):
print("* " * i)
case 3:
print("\nPyramid Pattern")
for i in range(rows):
print(" " * (rows - i - 1) + "* " * (i + 1))
case 4:
print("\nInverted Triangle")
for i in range(rows, 0, -1):
print("* " * i)
case _:
print("Invalid Choice")