-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPatterns.py
115 lines (89 loc) · 3.49 KB
/
Patterns.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
#Program 2 - To display the pattern based on the choice of the pattern given as input
while True:
print("You can choose to view the following programs:")
print("A : This will show you a cute pattern of odd numbers from 1 to 9!")
print("B : This will show you an interesting pattern of the numbers 1 to 5!")
print("C : This will show you a mind - blowing pattern of the letters from Q to Z!")
print("Exit: You may exit the program!")
print()
pattern_choice = input("Enter the pattern you want to view - a/b/c/Exit: ")
if pattern_choice.lower() == "a":
for i in range(1,10,2):
for j in range(i,0,-2):
print(j,end=" ")
print()
print()
elif pattern_choice.lower() == "b":
for i in range(1,6):
for j in range(1,6):
if (j <= i):
print(i,end=" ")
else:
print(j,end=" ")
print()
print()
elif pattern_choice.lower() == "c":
for i in range(90,80,-1):
for j in range(i,i+1):
if i==90 or i==88 or i==85:
print(chr(i),end="\n")
else:
print(chr(i),end=" ")
print()
print()
elif pattern_choice.lower() == "exit":
print()
print("The program will end now!")
print("Thank you!")
break
else:
print("Invalid choice!Please choose again!\n")
continue
"""You can choose to view the following programs:
A : This will show you a cute pattern of odd numbers from 1 to 9!
B : This will show you an interesting pattern of the numbers 1 to 5!
C : This will show you a mind - blowing pattern of the letters from Q to Z!
Exit: You may exit the program!
Enter the pattern you want to view - a/b/c/Exit: a
1
3 1
5 3 1
7 5 3 1
9 7 5 3 1
You can choose to view the following programs:
A : This will show you a cute pattern of odd numbers from 1 to 9!
B : This will show you an interesting pattern of the numbers 1 to 5!
C : This will show you a mind - blowing pattern of the letters from Q to Z!
Exit: You may exit the program!
Enter the pattern you want to view - a/b/c/Exit: b
1 2 3 4 5
2 2 3 4 5
3 3 3 4 5
4 4 4 4 5
5 5 5 5 5
You can choose to view the following programs:
A : This will show you a cute pattern of odd numbers from 1 to 9!
B : This will show you an interesting pattern of the numbers 1 to 5!
C : This will show you a mind - blowing pattern of the letters from Q to Z!
Exit: You may exit the program!
Enter the pattern you want to view - a/b/c/Exit: c
Z
Y X
W V U
T S R Q
You can choose to view the following programs:
A : This will show you a cute pattern of odd numbers from 1 to 9!
B : This will show you an interesting pattern of the numbers 1 to 5!
C : This will show you a mind - blowing pattern of the letters from Q to Z!
Exit: You may exit the program!
Enter the pattern you want to view - a/b/c/Exit: d
Invalid choice!Please choose again!
You can choose to view the following programs:
A : This will show you a cute pattern of odd numbers from 1 to 9!
B : This will show you an interesting pattern of the numbers 1 to 5!
C : This will show you a mind - blowing pattern of the letters from Q to Z!
Exit: You may exit the program!
Enter the pattern you want to view - a/b/c/Exit: exit
The program will end now!
Thank you!
"""