-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquestion11.py
More file actions
48 lines (40 loc) · 1.15 KB
/
question11.py
File metadata and controls
48 lines (40 loc) · 1.15 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
def question11():
print("Choose Pattern")
print("1. Pattern 1")
print("2. Pattern 2")
print("3. Pattern 3")
print("4. Pattern 4")
choice = int(input("Enter your choice (1-4): "))
height = int(input("Enter height:"))
print()
if choice == 1:
# Pattern 1
for i in range(1, height + 1):
for j in range(1, i + 1):
print(j, end="")
print()
elif choice == 2:
# Pattern 2
for i in range(1, height + 1):
for j in range(i):
print(i , end="")
print()
elif choice == 3:
# Pattern 3
for i in range(height, 0, -1):
for j in range(i, 0, -1):
print(j, end="")
print()
elif choice == 4:
# Pattern 4
for i in range(1,height +1):
#Increasing part
for j in range(1, i+1):
print(j, end="")
#Decreasing part
for j in range(i-1, 0, -1):
print(j, end="")
print()
else:
print("Invalid choice!")
question11()