├── .gitignore ├── Symbol Patterns ├── symbolpattern184.py ├── symbolpattern67.py ├── symbolpattern68.py ├── symbolicpattern170.py ├── symbolpattern111.py ├── symbolpattern9.py ├── symbolpattern8.py ├── symbolicpattern34.py ├── symbolpattern10.py ├── symbolpattern183.py ├── symbolpattern192.py ├── symbolicpattern103.py ├── symbolicpattern37.py ├── symbolicpattern38.py ├── symbolicpattern39.py ├── symbolicpattern40.py ├── symbolicpattern41.py ├── symbolpattern160.py ├── symbolicpattern28.py ├── symbolpattern186.py ├── symbolpattern200.py ├── symbolpattern11.py ├── symbolpattern112.py ├── symbolpattern113.py ├── symbolpattern188.py ├── symbolicpattern23.py ├── symbolpattern185.py ├── symbolpattern204.py ├── symbolicpattern169.py ├── symbolicpattern42.py ├── symbolpattern1.py ├── symbolpattern206.py ├── symbolpattern108.py ├── symbolicpattern43.py ├── symbolicpattern44.py ├── symbolicpattern46.py ├── symbolicpattern47.py ├── symbolpattern107.py ├── symbolpattern109.py ├── symbolicpattern20.py ├── symbolicpattern21.py ├── symbolicpattern48.py ├── symbolpattern154.py ├── symbolpattern156.py ├── symbolpattern158.py ├── symbolpattern191.py ├── symbolicpattern26.py ├── symbolicpattern24.py ├── symbolicpattern25.py ├── symbolpattern202.py ├── symbolicpattern22.py ├── symbolpattern189.py ├── symbolicpattern45.py ├── symbolpattern181.py ├── symbolpattern205.py ├── symbolicpattern33.py ├── symbolicpattern27.py ├── symbolpattern194.py ├── symbolpattern2.py ├── symbolpattern110.py ├── symbolpattern16.py ├── symbolpattern73.py ├── symbolicpattern180.py ├── symbolpattern14.py ├── symbolpattern15.py ├── symbolpattern3.py ├── symbolpattern69.py ├── symbolpattern70.py ├── symbolpattern161.py ├── symbolpattern18.py ├── symbolpattern19.py ├── symbolpattern71.py ├── symbolpattern72.py ├── symbolpattern74.py ├── symbolpattern95.py ├── symbolpattern153.py ├── symbolpattern196.py ├── symbolpattern17.py ├── symbolpattern199.py ├── symbolpattern7.py ├── symbolicpattern49.py ├── symbolpattern12.py ├── symbolpattern13.py ├── symbolpattern198.py ├── symbolpattern6.py ├── symbolpattern116.py ├── symbolpattern157.py ├── symbolpattern82.py ├── symbolpattern96.py ├── symbolpattern115.py ├── symbolpattern123.py ├── symbolpattern155.py ├── symbolpattern159.py ├── symbolpattern75.py ├── symbolpattern83.py ├── symbolpattern77.py ├── symbolpattern125.py ├── symbolpattern131.py ├── symbolpattern133.py ├── symbolpattern76.py ├── symbolpattern89.py ├── symbolpatter203.py ├── symbolpattern56.py ├── symbolpattern85.py ├── symbolicpattern104.py ├── symbolpattern79.py ├── symbolicpattern93.py ├── symbolpattern105.py ├── symbolpattern182.py ├── symbolpattern201.py ├── symbolpattern80.py ├── symbolpattern84.py ├── symbolicpattern36.py ├── symbolpattern132.py ├── symbolicpattern50.py ├── symbolicpattern51.py └── symbolpattern139.py ├── Alphabetic Patterns ├── alphabeticpattern175.py ├── desktop.ini ├── alphabeticpattern15.py ├── alphabeticpattern10.py ├── alphabeticpattern4.py ├── alphabeticpattern43.py ├── alphabeticpattern1.py ├── alphabeticpattern2.py ├── alphabeticpattern44.py ├── alphabeticpattern9.py ├── alphabeticpattern3.py ├── alphabeticpattern13.py ├── alphabeticpattern14.py ├── alphabeticpattern16.py ├── alphabeticpattern18.py ├── alphabeticpattern12.py ├── alphabeticpattern5.py ├── alphabeticpattern6.py ├── alphabeticpattern17.py ├── alphabeticpattern22.py ├── alphabeticpattern38.py ├── alphabeticpattern11.py ├── alphabeticpattern168.py ├── alphabeticpattern32.py ├── alphabeticpattern151.py ├── alphabeticpattern177.py ├── alphabeticpattern142.py ├── alphabeticpattern24.py ├── alphabeticpattern45.py ├── alphabeticpattern147.py ├── alphabeticpattern173.py ├── alphabeticpattern145.py ├── alphabeticpattern171.py ├── alphabeticpattern163.py ├── alphabeticpattern189.py ├── alphabeticpattern72.py ├── alphabeticpattern73.py ├── alphabeticpattern74.py ├── alphabeticpattern75.py ├── alphabeticpattern77.py ├── alphabeticpattern79.py ├── alphabeticpattern76.py ├── alphabeticpattern78.py ├── alphabeticpattern144.py ├── alphabeticpattern170.py ├── alphabeticpattern159.py ├── alphabeticpattern185.py ├── alphabeticpattern150.py ├── alphabeticpattern176.py ├── alphabeticpattern161.py ├── alphabeticpattern165.py ├── alphabeticpattern187.py ├── alphabeticpattern191.py ├── alphabeticpattern148.py ├── alphabeticpattern174.py ├── alphabeticpattern140.py ├── alphabeticpattern166.py ├── alphabeticpattern153.py ├── alphabeticpattern179.py ├── alphabeticpattern164.py ├── alphabeticpattern190.py ├── alphabeticpattern143.py ├── alphabeticpattern155.py ├── alphabeticpattern169.py ├── alphabeticpattern181.py ├── alphabeticpattern27.py ├── alphabeticpattern149.py ├── alphabeticpattern62.py ├── alphabeticpattern157.py ├── alphabeticpattern158.py ├── alphabeticpattern183.py ├── alphabeticpattern184.py ├── alphabeticpattern58.py ├── alphabeticpattern59.py ├── alphabeticpattern57.py ├── alphabeticpattern80.py ├── alphabeticpattern60.py ├── alphabeticpattern97.py ├── alphabeticpattern98.py ├── alphabeticpattern162.py ├── alphabeticpattern188.py ├── alphabeticpattern61.py ├── alphabeticpattern100.py ├── alphabeticpattern141.py ├── alphabeticpattern167.py ├── alphabeticpattern63.py └── alphabeticpattern99.py ├── String Patterns ├── stringpattern1.py ├── stringpattern14.py ├── desktop.ini ├── stringpattern13.py ├── stringpattern15.py ├── stringpattern3.py ├── stringpattern4.py ├── stringpattern2.py ├── stringpattern5.py ├── stringpattern6.py ├── stringpattern8.py ├── stringpattern11.py ├── stringpattern9.py ├── stringpattern7.py ├── stringpattern10.py └── stringpattern12.py ├── Numeric Patterns ├── desktop.ini ├── numericpattern25.py ├── numericpattern30.py ├── numericpattern1.py ├── numericpattern.py ├── numericpattern233.py ├── numericpattern63.py ├── numericpattern18.py ├── numericpattern2.py ├── numericpattern62.py ├── numericpattern128.py ├── numericpattern26.py ├── numericpattern57.py ├── numericpattern10.py ├── numericpattern65.py ├── numericpattern66.py ├── numericpattern67.py ├── numericpattern9.py ├── numericpattern4.py ├── numericpattern50.py ├── numericpattern44.py ├── numericpattern49.py ├── numericpattern131.py ├── numericpattern132.py ├── numericpattern290.py ├── numericpattern291.py ├── numericpattern41.py ├── numericpattern29.py ├── numericpattern28.py ├── numericpattern32.py ├── numericpattern58.py ├── numericpattern48.py ├── numericpattern113.py ├── numericpattern166.py ├── numericpattern27.py ├── numericpattern5.py ├── numericpattern59.py ├── numericpattern15.py ├── numericpattern171.py ├── numericpattern39.py ├── numericpattern60.py ├── numericpattern64.py ├── numericpattern222.py ├── numericpattern13.py ├── numericpattern38.py ├── numericpattern6.py ├── numericpattern7.py ├── numericpattern8.py ├── numericpattern11.py ├── numericpattern45.py ├── numericpattern16.py ├── numericpattern115.py ├── numericpattern143.py ├── numericpattern145.py ├── numericpattern151.py ├── numericpattern176.py ├── numericpattern149.py ├── numericpattern152.py ├── numericpattern153.py ├── numericpattern155.py ├── numericpattern275.py ├── numericpattern139.py ├── numericpattern148.py ├── numericpattern183.py ├── numericpattern184.py ├── numericpattern185.py ├── numericpattern186.py ├── numericpattern273.py ├── numericpattern34.py ├── numericpattern126.py ├── numericpattern129.py ├── numericpattern150.py ├── numericpattern154.py ├── numericpattern168.py ├── numericpattern272.py ├── numericpattern274.py ├── numericpattern127.py ├── numericpattern232.py ├── numericpattern69.py ├── numericpattern316.py ├── numericpattern326.py ├── numericpattern114.py ├── numericpattern174.py ├── numericpattern175.py ├── numericpattern179.py ├── numericpattern180.py ├── numericpattern181.py ├── numericpattern182.py ├── numericpattern234.py ├── numericpattern271.py ├── numericpattern68.py ├── numericpattern124.py ├── numericpattern144.py ├── numericpattern21.py ├── numericpattern22.py ├── numericpattern224.py ├── numericpattern23.py ├── numericpattern70.py ├── numericpattern147.py ├── numericpattern167.py ├── numericpattern17.py ├── numericpattern203.py ├── numericpattern204.py ├── numericpattern24.py ├── numericpattern141.py ├── numericpattern142.py ├── numericpattern160.py ├── numericpattern19.py ├── numericpattern199.py ├── numericpattern20.py ├── numericpattern200.py ├── numericpattern241.py ├── numericpattern242.py ├── numericpattern85.py ├── numericpattern201.py ├── numericpattern202.py ├── numericpattern86.py ├── numericpattern120.py ├── numericpattern133.py ├── numericpattern226.py ├── numericpattern228.py ├── numericpattern37.py ├── numericpattern164.py ├── numericpattern197.py ├── numericpattern198.py ├── numericpattern292.py ├── numericpattern293.py ├── numericpattern309.py ├── numericpattern31.py ├── numericpattern327.py ├── numericpattern84.py ├── numericpattern163.py ├── numericpattern227.py ├── numericpattern312.py ├── numericpattern322.py ├── numericpattern134.py ├── numericpattern177.py ├── numericpattern235.py ├── numericpattern12.py ├── numericpattern170.py ├── numericpattern317.py ├── numericpattern319.py ├── numericpattern61.py ├── numericpattern14.py ├── numericpattern162.py ├── numericpattern35.py ├── numericpattern116.py ├── numericpattern117.py ├── numericpattern118.py ├── numericpattern36.py ├── numericpattern169.py ├── numericpattern195.py ├── numericpattern196.py ├── numericpattern238.py ├── numericpattern250.py ├── numericpattern251.py ├── numericpattern254.py ├── numericpattern253.py ├── numericpattern94.py ├── numricpattern310.py ├── numericpattern189.py ├── numericpattern190.py ├── numericpattern191.py ├── numericpattern192.py ├── numericpattern194.py ├── numericpattern236.py ├── numericpattern239.py ├── numericpattern243.py ├── numericpattern246.py ├── numericpattern187.py ├── numericpattern188.py ├── numericpattern193.py ├── numericpattern262.py ├── numericpattern245.py └── numericpattern93.py ├── Pyramid Patterns ├── desktop.ini ├── pyramidpattern43.py ├── pyramidpattern44.py ├── pyramidpattern53.py ├── pyramidpattern39.py ├── pyramidpattern2.py ├── pyramidpattern3.py ├── pyramidpattern6.py ├── pyramidpattern7.py ├── pyramidpattern8.py ├── pyramidpattern11.py ├── pyramidpattern4.py ├── pyramidpattern40.py ├── pyramidpattern42.py ├── pyramidpattern5.py ├── pyramidpattern10.py ├── pyramidpattern12.py ├── pyramidpattern13.py ├── pyramidpattern15.py ├── pyramidpattern16.py ├── pyramidpattern17.py ├── pyramidpattern36.py ├── pyramidpattern37.py ├── pyramidpattern41.py ├── pyramidpattern14.py ├── pyramidpattern9.py ├── pyramidpattern29.py ├── pyramidpattern31.py ├── pyramidpattern1.py ├── pyramidpattern93.py ├── pyramidpattern20.py ├── pyramidpattern18.py ├── pyramidpattern30.py ├── pyramidpattern32.py ├── pyramidpattern63.py ├── pyramidpattern19.py ├── pyramidpattern21.py ├── pyramidpattern38.py └── pyramidpattern80.py ├── Series Patterns ├── desktop.ini ├── seriespattern3.py ├── seriespattern4.py ├── seriespattern5.py ├── seriespattern6.py ├── seriespattern7.py └── seriespattern9.py ├── Spiral Patterns └── desktop.ini └── Wave Patterns └── desktop.ini /.gitignore: -------------------------------------------------------------------------------- 1 | test.sh 2 | *.pyc 3 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern184.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern175.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /String Patterns/stringpattern1.py: -------------------------------------------------------------------------------- 1 | for i in range(5): 2 | print("HOUSE") -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern67.py: -------------------------------------------------------------------------------- 1 | n = int(input("Enter the number of rows: ")) 2 | for i in range(0, n+1): 3 | print(i, "*"*i) 4 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern68.py: -------------------------------------------------------------------------------- 1 | n = int(input("Enter the number of rows: ")) 2 | for i in range(n, -1, -1): 3 | print(i, "*"*i) 4 | -------------------------------------------------------------------------------- /String Patterns/stringpattern14.py: -------------------------------------------------------------------------------- 1 | s = "ARYA" 2 | for i in range(len(s)): 3 | print(s[:i+1]) 4 | for i in range(len(s)-1, 0, -1): 5 | print(s[:i]) -------------------------------------------------------------------------------- /Numeric Patterns/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | IconResource=C:\WINDOWS\System32\SHELL32.dll,265 3 | [ViewState] 4 | Mode= 5 | Vid= 6 | FolderType=Documents 7 | -------------------------------------------------------------------------------- /Pyramid Patterns/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | IconResource=C:\WINDOWS\System32\SHELL32.dll,265 3 | [ViewState] 4 | Mode= 5 | Vid= 6 | FolderType=Documents 7 | -------------------------------------------------------------------------------- /Series Patterns/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | IconResource=C:\WINDOWS\System32\SHELL32.dll,144 3 | [ViewState] 4 | Mode= 5 | Vid= 6 | FolderType=Documents 7 | -------------------------------------------------------------------------------- /Spiral Patterns/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | IconResource=C:\WINDOWS\System32\SHELL32.dll,144 3 | [ViewState] 4 | Mode= 5 | Vid= 6 | FolderType=Documents 7 | -------------------------------------------------------------------------------- /String Patterns/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | IconResource=C:\WINDOWS\System32\SHELL32.dll,265 3 | [ViewState] 4 | Mode= 5 | Vid= 6 | FolderType=Documents 7 | -------------------------------------------------------------------------------- /Wave Patterns/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | IconResource=C:\WINDOWS\System32\SHELL32.dll,144 3 | [ViewState] 4 | Mode= 5 | Vid= 6 | FolderType=Documents 7 | -------------------------------------------------------------------------------- /Alphabetic Patterns/desktop.ini: -------------------------------------------------------------------------------- 1 | [.ShellClassInfo] 2 | IconResource=C:\WINDOWS\System32\SHELL32.dll,265 3 | [ViewState] 4 | Mode= 5 | Vid= 6 | FolderType=Documents 7 | -------------------------------------------------------------------------------- /String Patterns/stringpattern13.py: -------------------------------------------------------------------------------- 1 | s = "PatternHouse" 2 | n = 5 3 | s *= (n**2//len(s)+1) 4 | c = 0 5 | for i in range(1, n): 6 | print(" "*(n-i)+s[c:c+(i*2)-1]) 7 | c += i -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern15.py: -------------------------------------------------------------------------------- 1 | n = int(input("Number of rows: ")) 2 | 3 | for i in range(n): 4 | for j in range(n - i): 5 | print(chr(65 + j), end="") 6 | print() -------------------------------------------------------------------------------- /Symbol Patterns/symbolicpattern170.py: -------------------------------------------------------------------------------- 1 | symbol_list=[4,3,5,1,2] 2 | for i in range(5): 3 | print([i+1], end='') 4 | for j in range(symbol_list[i]): 5 | print('#', end=' ') 6 | print(end='\n') -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern10.py: -------------------------------------------------------------------------------- 1 | row = int(input("Enter number of rows : ")) 2 | for i in range(1, row+1): 3 | for j in range(65, 65+i): 4 | print(chr(j), end=' ') 5 | print() -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern4.py: -------------------------------------------------------------------------------- 1 | size = int(input("Number of rows: ")) 2 | 3 | for i in range(size): 4 | for j in range(65+size-1,64,-1): 5 | print(chr(j), end=' ') 6 | print() -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern25.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows: ") 2 | n = int(input()) 3 | for i in range(1, n+1): 4 | for j in range(1, i+1): 5 | print(i, end=" ") 6 | print() 7 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern43.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | count = n-1 4 | for i in range(n): 5 | print(" "*i + alpha[count]*(2*(n-i)-1)) 6 | count-=1 7 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern1.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows: ") 2 | n = int(input()) 3 | for i in range(1, n+1): 4 | for j in range(1, n+1): 5 | print(chr(i+64), end=" ") 6 | print() 7 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern2.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows: ") 2 | n = int(input()) 3 | for i in range(1, n+1): 4 | for j in range(1, n+1): 5 | print(chr(j+64), end=" ") 6 | print() 7 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern44.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | count = 2*n-2 4 | for i in range(n): 5 | print(" "*i + alpha[count]*(2*(n-i)-1)) 6 | count-=2 7 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern9.py: -------------------------------------------------------------------------------- 1 | n = int(input("Number of rows: ")) 2 | 3 | for i in range(65, 65+n): 4 | for j in range(64, i): 5 | a = chr(i) 6 | print(a, end="") 7 | print() -------------------------------------------------------------------------------- /Series Patterns/seriespattern3.py: -------------------------------------------------------------------------------- 1 | n = 5 # limit or size 2 | 3 | for x in range(1, n + 1): 4 | print(" " + str(2 * x - 1), end="") 5 | 6 | """ 7 | OUTPUT: 8 | 9 | 1 3 5 7 9 10 | 11 | """ -------------------------------------------------------------------------------- /Series Patterns/seriespattern4.py: -------------------------------------------------------------------------------- 1 | n = 5 # limit or size 2 | 3 | for x in range(1, n + 1): 4 | print(" " + str(2 * x), end="") 5 | 6 | """ 7 | OUTPUT: 8 | 9 | 2 4 6 8 10 10 | 11 | """ -------------------------------------------------------------------------------- /Series Patterns/seriespattern5.py: -------------------------------------------------------------------------------- 1 | n = 5 # limit or size 2 | 3 | for x in range(1, n + 1): 4 | print(" " + str(x * x), end="") 5 | 6 | """ 7 | OUTPUT: 8 | 9 | 1 4 9 16 25 10 | 11 | """ -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern111.py: -------------------------------------------------------------------------------- 1 | n=5 2 | for i in range (n): 3 | for j in range (n-i-1): 4 | print(' ', end='') 5 | for k in range (2*i+2): 6 | print('*', end='') 7 | print() 8 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern3.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows: ") 2 | n = int(input()) 3 | for i in range(n, 0, -1): 4 | for j in range(n, 0, -1): 5 | print(chr(i+64), end=" ") 6 | print() 7 | -------------------------------------------------------------------------------- /Series Patterns/seriespattern6.py: -------------------------------------------------------------------------------- 1 | n = 5 # limit or size 2 | 3 | for x in range(1, n + 1): 4 | print(" " + str(x * x * x), end="") 5 | 6 | """ 7 | OUTPUT: 8 | 9 | 1 8 27 64 125 10 | 11 | """ -------------------------------------------------------------------------------- /String Patterns/stringpattern15.py: -------------------------------------------------------------------------------- 1 | s = "ABCDE" 2 | half = round(len(s)/2) 3 | for i in range(len(s)): 4 | if i == half: 5 | print(" ".join(s)) 6 | elif i != half: 7 | print(" "*(half*2)+s[i]) -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern13.py: -------------------------------------------------------------------------------- 1 | size = int(input("Enter Number of Rows: ")) 2 | for i in range(0, size): 3 | for j in range(65 + i, 64, -1): 4 | a = chr(j) 5 | print(a, end="") 6 | print() -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern14.py: -------------------------------------------------------------------------------- 1 | size = int(input("Enter Number of Rows: ")) 2 | for i in range(65, 65+size): 3 | for j in range(i, 65+size): 4 | a = chr(i) 5 | print(a, end="") 6 | print() -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern16.py: -------------------------------------------------------------------------------- 1 | size = int(input("Enter Number of Rows: ")) 2 | for i in range(65+size -1, 64, -1): 3 | for j in range(64, i): 4 | a = chr(i) 5 | print(a, end="") 6 | print() -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern18.py: -------------------------------------------------------------------------------- 1 | size = int(input("Enter Number of Rows: ")) 2 | for i in range(0, size): 3 | for j in range(64+size-i, 64, -1): 4 | a = chr(j) 5 | print(a, end="") 6 | print() -------------------------------------------------------------------------------- /String Patterns/stringpattern3.py: -------------------------------------------------------------------------------- 1 | print('Enter a string') 2 | pattern_string = input() 3 | for i in range (len(pattern_string)) : 4 | for ch in pattern_string [0:i+1] : 5 | print(ch, end =' ') 6 | print(end ='\n') 7 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern9.py: -------------------------------------------------------------------------------- 1 | n = 5 2 | for i in range(n): 3 | print(" "*i + "*"*(2*(n-i)-1)) 4 | 5 | """ 6 | OUTPUT: 7 | 8 | ********* 9 | ******* 10 | ***** 11 | *** 12 | * 13 | """ -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern12.py: -------------------------------------------------------------------------------- 1 | size = int(input("Enter Number of Rows: ")) 2 | for i in range(65+size, 64, -1): 3 | for j in range(65+size, i, -1): 4 | a = chr(i) 5 | print(a, end="") 6 | print() -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern8.py: -------------------------------------------------------------------------------- 1 | n = 5 # size 2 | for i in range(n): 3 | print(" "*(-1*i+n-1)+"*"*(2*i+1)) 4 | 5 | """ 6 | OUTPUT: 7 | 8 | * 9 | *** 10 | ***** 11 | ******* 12 | ********* 13 | """ -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern30.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows: ") 2 | n = int(input()) 3 | for i in range(1, n+1): 4 | k = 2 5 | for j in range(1, i+1): 6 | print(k, end=" ") 7 | k = k + 2 8 | print() 9 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern5.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows: ") 2 | n = int(input()) 3 | k = 1 4 | for i in range(0, n): 5 | for j in range(1, n+1): 6 | k = k + 1 7 | print(chr(k+63), end=" ") 8 | print() 9 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern6.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows: ") 2 | n = int(input()) 3 | k = 1 4 | for i in range(0, n): 5 | for j in range(1, n+1): 6 | k = i + j 7 | print(chr(k+64), end=" ") 8 | print() 9 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern1.py: -------------------------------------------------------------------------------- 1 | # Numeric Pattern 1 2 | 3 | """ 4 | Desired Pattern: 5 | 1 1 1 1 1 6 | 2 2 2 2 2 7 | 3 3 3 3 3 8 | 4 4 4 4 4 9 | 5 5 5 5 5 10 | """ 11 | 12 | for i in range(1, 6): 13 | print(f"{i} " * 5) 14 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern.py: -------------------------------------------------------------------------------- 1 | # Numeric Pattern 3 2 | 3 | """ 4 | Desired Pattern: 5 | 5 5 5 5 5 6 | 4 4 4 4 4 7 | 3 3 3 3 3 8 | 2 2 2 2 2 9 | 1 1 1 1 1 10 | """ 11 | 12 | for i in range(5, 0, -1): 13 | print(f"{i} " * 5) 14 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern17.py: -------------------------------------------------------------------------------- 1 | row = int(input("Enter number of rows : ")) 2 | for i in range (65,65+row): 3 | # inner loop for jth columns 4 | for j in range(65+row-1,i-1,-1): 5 | print(chr(j),end="") 6 | 7 | print() -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern233.py: -------------------------------------------------------------------------------- 1 | for i in range(1,6): 2 | for j in range(1,6): 3 | if i==int(5/2)+1 or j==int(5/2)+1: 4 | print(abs(i-j),end=' ') 5 | else: 6 | print(" ",end=' ') 7 | print(end='\n') 8 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolicpattern34.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows: ") 2 | a = int(input()) 3 | counter = 1 4 | for i in range(0, a): 5 | for j in range(0, i + 1): 6 | print(str(counter) + "#", end=" ") 7 | counter += 1 8 | print() 9 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern22.py: -------------------------------------------------------------------------------- 1 | size = int(input("Number of Rows: ")) 2 | for i in range(size): 3 | for j in range(1, size - i): 4 | print(" ", end="") 5 | for k in range(i + 1): 6 | print(chr(65 + k), end="") 7 | print() -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern63.py: -------------------------------------------------------------------------------- 1 | 2 | print("Enter the number of rows:") 3 | n = int(input()) 4 | count = 17 5 | for i in range(0,n): 6 | for j in range(0,n-i): 7 | print(count,end=" ") 8 | count+=1 9 | print() 10 | 11 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern43.py: -------------------------------------------------------------------------------- 1 | n = 4 2 | for i in range(n+1): 3 | print("* "*i) 4 | for i in range(n-1, 0, -1): 5 | print("* "*i) 6 | 7 | """ 8 | OUTPUT: 9 | * 10 | * * 11 | * * * 12 | * * * * 13 | * * * 14 | * * 15 | * 16 | """ 17 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern38.py: -------------------------------------------------------------------------------- 1 | n = int(input("Enter number of rows : ")) 2 | for i in range(n): 3 | for j in range(n - i - 1): 4 | print(' ', end='') 5 | for k in range(2 * i + 1): 6 | print(chr(65 + k), end='') 7 | print() 8 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern18.py: -------------------------------------------------------------------------------- 1 | #18 - Numeric Pattern 2 | nums = ['1'] 3 | 4 | for i in range(12): 5 | nums += ['0', '1'] 6 | 7 | # Printing 5 nums per loop 8 | i = 0 9 | for _ in range(5): 10 | print(" ".join(nums[i : i + 5])) 11 | i += 5 -------------------------------------------------------------------------------- /String Patterns/stringpattern4.py: -------------------------------------------------------------------------------- 1 | print('Enter a string') 2 | pattern_string = input() 3 | str_length = len(pattern_string) 4 | for i in range (str_length) : 5 | for ch in pattern_string [0:str_length-i] : 6 | print(ch, end =' ') 7 | print(end ='\n') 8 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern2.py: -------------------------------------------------------------------------------- 1 | # Numeric Pattern 2 2 | 3 | """ 4 | Desired Output: 5 | 1 2 3 4 5 6 | 1 2 3 4 5 7 | 1 2 3 4 5 8 | 1 2 3 4 5 9 | """ 10 | 11 | pattern = " ".join(map(str, list(range(1, 6)))) 12 | for _ in range(5): 13 | print(pattern) 14 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern10.py: -------------------------------------------------------------------------------- 1 | n = 4 2 | for i in range(n+1): 3 | print("* "*i) 4 | for i in range(n-1, 0, -1): 5 | print("* "*i) 6 | 7 | """ 8 | OUTPUT: 9 | 10 | * 11 | * * 12 | * * * 13 | * * * * 14 | * * * 15 | * * 16 | * 17 | """ -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern62.py: -------------------------------------------------------------------------------- 1 | 2 | print("Enter the number of rows:") 3 | n = int(input()) 4 | count = int(n*n/2+n/2) 5 | for i in range(0,n): 6 | for j in range(0,n-i): 7 | print(count,end=" ") 8 | count-=1 9 | print() 10 | 11 | -------------------------------------------------------------------------------- /Series Patterns/seriespattern7.py: -------------------------------------------------------------------------------- 1 | n = 15 # upper limit 2 | a = 0 3 | b = 1 4 | c = a + b 5 | while (c <= n): 6 | print(" " + str(c), end="") 7 | c = a + b 8 | a = b 9 | b = c 10 | 11 | """ 12 | OUTPUT: 13 | 14 | 1 1 2 3 5 8 13 15 | 16 | """ -------------------------------------------------------------------------------- /String Patterns/stringpattern2.py: -------------------------------------------------------------------------------- 1 | print('Enter a string') 2 | pattern_string = input() 3 | print('Enter the number of lines') 4 | lines = int(input()) 5 | for i in range(lines) : 6 | for ch in pattern_string [::-1] : 7 | print(ch, end =' ') 8 | print(end ='\n') 9 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern183.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | for i in range(0, height): 3 | print("*", end="") 4 | for j in range(0, height - 1): 5 | if i == 0 or i == height - 1: 6 | print("*", end="") 7 | else: 8 | continue 9 | print() -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern128.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows: ") 2 | n = int(input()) 3 | for i in range(n): 4 | count = i 5 | for j in range(i,n): 6 | print(j+1, end=" ") 7 | for j in range(i-1,0,-1): 8 | print(j); 9 | print("\n") 10 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern26.py: -------------------------------------------------------------------------------- 1 | rows = 5 2 | for i in range(1, rows + 1): 3 | for j in range(1, i + 1): 4 | print(j, end=' ') 5 | print('') 6 | 7 | ''' 8 | 9 | Output: 10 | 11 | 1 12 | 1 2 13 | 1 2 3 14 | 1 2 3 4 15 | 1 2 3 4 5 16 | 17 | ''' 18 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern11.py: -------------------------------------------------------------------------------- 1 | # Left triangle pattern 2 | n = 5 3 | for i in range(n): 4 | for j in range(i+1): 5 | print(chr(69-j), end="") 6 | print() 7 | 8 | ''' 9 | 10 | Output: 11 | E 12 | ED 13 | EDC 14 | EDCB 15 | EDCBA 16 | 17 | ''' 18 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern168.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | for i in range(0, height): 3 | print("*", end="") 4 | for j in range(0, height - 1): 5 | if i == 0 or i == height - 1: 6 | print("*", end="") 7 | else: 8 | continue 9 | print() -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern32.py: -------------------------------------------------------------------------------- 1 | num=int(input("Enter Number of Rows:")) 2 | for i in range(65, 65+num): 3 | for j in range(75+num, i, -1): 4 | print(" ", end="") 5 | for k in range(65, i+1): 6 | a = chr(k) 7 | print(a, end=" ") 8 | print() -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern44.py: -------------------------------------------------------------------------------- 1 | n = 4 2 | for i in range(n+1): 3 | for j in range(0,i): 4 | print(n-j-1, end = " ") 5 | print() 6 | for i in range(n-1, 0, -1): 7 | for j in range(0,i): 8 | print(n-j-1, end = " ") 9 | print() 10 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern57.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows and starting number respectively: ") 2 | n, i = map(int, input().split()) 3 | b = n 4 | for j in range(0, n): 5 | for k in range(b, 0, -1): 6 | print(i, end=" ") 7 | i = i - 1 8 | b = b - 1 9 | print() -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern192.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | for i in range(0, height): 3 | print("*", end="") 4 | for j in range(0, height+1): 5 | if (i == height - 1): 6 | print("*", end="") 7 | else: 8 | print(end=" ") 9 | print() 10 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern151.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | for i in range(0, height): 3 | print("*", end="") 4 | for j in range(0, height+1): 5 | if (i == height - 1): 6 | print("*", end="") 7 | else: 8 | print(end=" ") 9 | print() 10 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern177.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | for i in range(0, height): 3 | print("L", end="") 4 | for j in range(0, height+1): 5 | if (i == height - 1): 6 | print("L", end="") 7 | else: 8 | print(end=" ") 9 | print() 10 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern10.py: -------------------------------------------------------------------------------- 1 | # Numeric Pattern 10 2 | 3 | """ 4 | 5 | 1 1 1 2 1 3 6 | 2 1 2 2 2 3 7 | 3 1 3 2 3 3 8 | 4 1 4 2 4 3 9 | 5 1 5 2 5 3 10 | 11 | """ 12 | 13 | for i in range(1, 6): 14 | for j in range(1, 4): 15 | print(i,j, end=" ") 16 | print() 17 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern65.py: -------------------------------------------------------------------------------- 1 | 2 | print("Enter the number of rows:") 3 | n = int(input()) 4 | for i in range(0,n): 5 | for j in range(0,n-i): 6 | if(i%2==0): 7 | print("1",end=" ") 8 | else: 9 | print("0",end=" ") 10 | print() 11 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern66.py: -------------------------------------------------------------------------------- 1 | 2 | print("Enter the number of rows:") 3 | n = int(input()) 4 | for i in range(0,n): 5 | for j in range(0,n-i): 6 | if(i%2!=0): 7 | print("1",end=" ") 8 | else: 9 | print("0",end=" ") 10 | print() 11 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern67.py: -------------------------------------------------------------------------------- 1 | 2 | print("Enter the number of rows:") 3 | n = int(input()) 4 | for i in range(0,n): 5 | for j in range(0,n-i): 6 | if(j%2==0): 7 | print("1",end=" ") 8 | else: 9 | print("0",end=" ") 10 | print() 11 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolicpattern103.py: -------------------------------------------------------------------------------- 1 | n = int(input("Number of rows: ")) 2 | for i in range(n-1, 0, -1): 3 | for j in range(0, i+1): 4 | print("* ", end="") 5 | print("\r") 6 | for i in range(0,n): 7 | for j in range(0, i+1): 8 | print("* " , end="") 9 | print("\r") -------------------------------------------------------------------------------- /Symbol Patterns/symbolicpattern37.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows: ") 2 | n = int(input()) 3 | for i in range(0, n): 4 | for j in range(0, i+1): 5 | if i % 2 == 0: 6 | print("#", end=" ") 7 | else: 8 | print("*", end=" ") 9 | print() 10 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolicpattern38.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows: ") 2 | n = int(input()) 3 | for i in range(0, n): 4 | for j in range(0, i+1): 5 | if j % 2 == 0: 6 | print("#", end=" ") 7 | else: 8 | print("*", end=" ") 9 | print() 10 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolicpattern39.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows: ") 2 | n = int(input()) 3 | for i in range(0, n): 4 | for j in range(0, i+1): 5 | if i % 2 == 0: 6 | print(i+1, end=" ") 7 | else: 8 | print("*", end=" ") 9 | print() 10 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolicpattern40.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows: ") 2 | n = int(input()) 3 | for i in range(0, n): 4 | for j in range(0, i+1): 5 | if i % 2 == 0: 6 | print(j+1, end=" ") 7 | else: 8 | print("*", end=" ") 9 | print() 10 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolicpattern41.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows: ") 2 | n = int(input()) 3 | for i in range(0, n): 4 | for j in range(0, i+1): 5 | if j % 2 == 0: 6 | print(j+1, end=" ") 7 | else: 8 | print("*", end=" ") 9 | print() 10 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern142.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | for i in range(0, height): 3 | print("*", end="") 4 | for j in range(0, height - 1): 5 | if i == 0 or i == height - 1: 6 | print("*", end="") 7 | else: 8 | continue 9 | print() 10 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern9.py: -------------------------------------------------------------------------------- 1 | # Numeric Pattern 9 2 | 3 | """ 4 | 5 | 1 1 2 1 3 1 6 | 1 2 2 2 3 2 7 | 1 3 2 3 3 3 8 | 1 4 2 4 3 4 9 | 1 5 2 5 3 5 10 | 11 | """ 12 | 13 | for i in range(1, 6): 14 | for j in range(1, 4): 15 | print(j,i, end=" ") 16 | print() 17 | 18 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern160.py: -------------------------------------------------------------------------------- 1 | n = 6 2 | counter = 3 3 | iterations = 0 4 | for i in range(0, n): 5 | for j in range(0, counter): 6 | print("*", end=" ") 7 | iterations = iterations + 1 8 | if iterations % 2 == 0: 9 | counter = counter - 1 10 | print() 11 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern24.py: -------------------------------------------------------------------------------- 1 | num=int(input("Enter Number of Rows:")) 2 | for i in range(65, 64+num+1): 3 | for j in range(64+num, 64, -1): 4 | if(j <= i): 5 | a = chr(j) 6 | print(a, end="") 7 | else: 8 | print(" ", end="") 9 | print() -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern45.py: -------------------------------------------------------------------------------- 1 | n = int(input("Enter number of rows : ")) 2 | for i in range(n): 3 | # printing spaces 4 | for j in range(i): 5 | print(' ', end='') 6 | # printing alphabet 7 | for j in range(2*(n-i)-1): 8 | print(chr(65 + j), end='') 9 | print() -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern4.py: -------------------------------------------------------------------------------- 1 | # Numeric Pattern 4 2 | 3 | """ 4 | Desired Pattern: 5 | 6 | 5 4 3 2 1 7 | 5 4 3 2 1 8 | 5 4 3 2 1 9 | 5 4 3 2 1 10 | 5 4 3 2 1 11 | 12 | """ 13 | 14 | pattern = " ".join(map(str, list(range(5, 0, -1)))) 15 | for _ in range(5): 16 | print(pattern) 17 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern50.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows:") 2 | n = int(input()) 3 | a = 1 4 | for i in range(0, n): 5 | for j in range(0, i+1): 6 | if i % 2 == 0: 7 | a = 1 8 | else: 9 | a = 0 10 | print(a, end=" ") 11 | print() -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern44.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows and starting number respectively: ") 2 | n, i = map(int, input().split()) 3 | for x in range(0, n): 4 | for j in range(0, x+1): 5 | if x == 1: 6 | i = i - 1 7 | print(i, end=" ") 8 | i = i + 1 9 | print() -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern49.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows:") 2 | n = int(input()) 3 | a = 0 4 | for i in range(0, n): 5 | for j in range(0, i+1): 6 | if i % 2 == 0: 7 | a = 0 8 | else: 9 | a = 1 10 | print(a, end=" ") 11 | print() 12 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern53.py: -------------------------------------------------------------------------------- 1 | n = 4 2 | for i in range(n+1): 3 | print(" "*(2*(n-i))+"* "*i) 4 | for i in range(n-1, 0, -1): 5 | print(" "*(2*(n-i))+"* "*i) 6 | 7 | """ 8 | OUTPUT: 9 | * 10 | * * 11 | * * * 12 | * * * * 13 | * * * 14 | * * 15 | * 16 | """ 17 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern131.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows: ") 2 | n = int(input()) 3 | count = 0 4 | for i in range(n): 5 | flag = 0 6 | for j in range(n): 7 | print(count+1, end=" ") 8 | if(count<4): 9 | count+=2 10 | else: 11 | count-=2 12 | print() 13 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern132.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows: ") 2 | n = int(input()) 3 | count = 0 4 | for i in range(n): 5 | flag = 0 6 | for j in range(n): 7 | print(count+1, end=" ") 8 | if(count<4): 9 | count+=2 10 | else: 11 | count-=2 12 | print() 13 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolicpattern28.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows: ") 2 | a = int(input()) 3 | b = a 4 | for i in range(0, a): 5 | for j in range(1, a+1): 6 | if j == b: 7 | print("*", end=" ") 8 | else: 9 | print(j, end=" ") 10 | b = b - 1 11 | print() 12 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern186.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | for i in range(0, height): 3 | print("*", end="") 4 | for j in range(0, height): 5 | if ((i == 0) or (i == height // 2 and j <= height // 2)): 6 | print("*", end="") 7 | else: 8 | continue 9 | print() 10 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern147.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | for i in range(0, height): 3 | print("*", end="") 4 | for j in range(0, height): 5 | if ((j == height - 1) or (i == height // 2)): 6 | print("*", end="") 7 | else: 8 | print(end=" ") 9 | print() 10 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern173.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | for i in range(0, height): 3 | print("H", end="") 4 | for j in range(0, height): 5 | if ((j == height - 1) or (i == height // 2)): 6 | print("H", end="") 7 | else: 8 | print(end=" ") 9 | print() 10 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern290.py: -------------------------------------------------------------------------------- 1 | height = 3 2 | 3 | for i in range(height,-height-1,-1): 4 | 5 | for j in range(0,abs(i)+1): 6 | print(j,end=" ") 7 | 8 | print() 9 | 10 | # Output :- 11 | # 0 1 2 3 12 | # 0 1 2 13 | # 0 1 14 | # 0 15 | # 0 1 16 | # 0 1 2 17 | # 0 1 2 3 18 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern200.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | for i in range(0, height): 3 | for j in range(0, height): 4 | if i == 0: 5 | print("*", end="") 6 | elif j == height // 2: 7 | print("*", end="") 8 | else: 9 | print(end=" ") 10 | print() 11 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern145.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | for i in range(0, height): 3 | print("*", end="") 4 | for j in range(0, height): 5 | if ((i == 0) or (i == height // 2 and j <= height // 2)): 6 | print("*", end="") 7 | else: 8 | continue 9 | print() 10 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern171.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | for i in range(0, height): 3 | print("F", end="") 4 | for j in range(0, height): 5 | if ((i == 0) or (i == height // 2 and j <= height // 2)): 6 | print("F", end="") 7 | else: 8 | continue 9 | print() 10 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern291.py: -------------------------------------------------------------------------------- 1 | height = 3 2 | 3 | for i in range(height,-height-1,-1): 4 | 5 | for j in range(abs(i),-1,-1): 6 | print(j,end=" ") 7 | 8 | print() 9 | 10 | # Output :- 11 | # 3 2 1 0 12 | # 2 1 0 13 | # 1 0 14 | # 0 15 | # 1 0 16 | # 2 1 0 17 | # 3 2 1 0 18 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern41.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows and starting number respectively: ") 2 | n, i = map(int, input().split()) 3 | counter = 1 4 | for x in range(0, n): 5 | for j in range(0, counter): 6 | print(i, end=" ") 7 | i = i - 1 8 | counter = counter + 1 9 | print() 10 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern11.py: -------------------------------------------------------------------------------- 1 | n = 4 2 | for i in range(n+1): 3 | print(" "*(2*(n-i))+"* "*i) 4 | for i in range(n-1, 0, -1): 5 | print(" "*(2*(n-i))+"* "*i) 6 | 7 | """ 8 | OUTPUT: 9 | 10 | * 11 | * * 12 | * * * 13 | * * * * 14 | * * * 15 | * * 16 | * 17 | """ -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern112.py: -------------------------------------------------------------------------------- 1 | n = 5 2 | for i in range (n): 3 | j = -1 4 | for j in range (n-i-1): 5 | print(' ', end='') 6 | for k in range (2*i+1) : 7 | if (j+k)%2 != 0: 8 | print('*', end='') 9 | else: 10 | print('#', end='') 11 | print() 12 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern113.py: -------------------------------------------------------------------------------- 1 | n = 5 2 | for i in range (n): 3 | j = -1 4 | for j in range (n-i-1): 5 | print(' ', end='') 6 | for k in range (i+1) : 7 | print('(', end='') 8 | print('*', end='') 9 | for l in range (i+1): 10 | print(')', end='') 11 | print() 12 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern188.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | for i in range(0,height) : 3 | print("*",end="") 4 | for j in range(0,height) : 5 | if ( (j == height - 1) or (i == height // 2) ): 6 | print("*",end="") 7 | else : 8 | print(end=" ") 9 | print() -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern29.py: -------------------------------------------------------------------------------- 1 | 2 | print("Enter the number of rows:") 3 | n = int(input()) 4 | column_count=n 5 | for i in range(0,n): 6 | row_count = column_count 7 | for j in range(0,i+1): 8 | print(row_count,end=" ") 9 | row_count+=1 10 | column_count-=1 11 | print() 12 | 13 | -------------------------------------------------------------------------------- /String Patterns/stringpattern5.py: -------------------------------------------------------------------------------- 1 | print('Enter a string') 2 | pattern_string = input() 3 | str_length = len(pattern_string) 4 | for i in range (str_length) : 5 | for j in range(i,str_length-1) : 6 | print(' ', end =' ') 7 | for ch in pattern_string [0:i+1] : 8 | print(ch, end =' ') 9 | print(end ='\n') 10 | -------------------------------------------------------------------------------- /String Patterns/stringpattern6.py: -------------------------------------------------------------------------------- 1 | print('Enter a string') 2 | pattern_string = input() 3 | str_length = len(pattern_string) 4 | for i in range (str_length) : 5 | for j in range(0,i) : 6 | print(' ', end =' ') 7 | for ch in pattern_string [0:str_length-i] : 8 | print(ch, end =' ') 9 | print(end ='\n') 10 | -------------------------------------------------------------------------------- /String Patterns/stringpattern8.py: -------------------------------------------------------------------------------- 1 | print('Enter a string') 2 | pattern_string = input() [::-1] 3 | l1=[] 4 | l1.append(pattern_string[4:8]) 5 | l1.append(pattern_string[8:]) 6 | l1.append(pattern_string[0:4]) 7 | for i in range (3): 8 | for j in range (4): 9 | print(l1[i][j], end=' ') 10 | print(end ='\n') 11 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern28.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(height,0,-1) : 4 | 5 | for j in range(height, i-1,-1): 6 | print(j,end = " ") 7 | 8 | print() 9 | 10 | # Sample Input :- 5 11 | # output :- 12 | # 5 13 | # 5 4 14 | # 5 4 3 15 | # 5 4 3 2 16 | # 5 4 3 2 1 17 | 18 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern32.py: -------------------------------------------------------------------------------- 1 | 2 | print("Enter the number of rows:") 3 | n = int(input()) 4 | column_count=0 5 | for i in range(0,n): 6 | row_count = column_count+1 7 | for j in range(0,i+1): 8 | print(row_count,end=" ") 9 | row_count+=1 10 | column_count+=1 11 | print() 12 | 13 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern58.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows and starting number respectively: ") 2 | n, i = map(int, input().split()) 3 | a = i 4 | b = n 5 | for j in range(0, n): 6 | for k in range(b, 0, -1): 7 | print(i, end=" ") 8 | i = i - 1 9 | i = a 10 | b = b - 1 11 | print() 12 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolicpattern23.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows: ") 2 | a = int(input()) 3 | b = a 4 | for i in range(0, a): 5 | for j in range(0, a): 6 | if j in range(0, b): 7 | print(chr(j+65), end=" ") 8 | else: 9 | print("*", end=" ") 10 | b = b - 1 11 | print() 12 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern185.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | for i in range(0, height): 3 | print("*", end="") 4 | for j in range(0, height): 5 | if ((i == 0 or i == height - 1) or (i == height // 2 and j <= height // 2)): 6 | print("*", end="") 7 | else: 8 | continue 9 | print() 10 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern204.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | counter = 0 3 | for i in range(0, height + 1): 4 | for j in range(0, height + 1): 5 | if j == counter or j == height - counter: 6 | print("*", end="") 7 | else: 8 | print(end=" ") 9 | counter = counter + 1 10 | print() 11 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern163.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | counter = 0 3 | for i in range(0, height+1): 4 | for j in range(0, height+1): 5 | if (j == counter or j == height - counter): 6 | print("*", end="") 7 | else: 8 | print(end=" ") 9 | counter = counter + 1 10 | print() 11 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern189.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | counter = 0 3 | for i in range(0, height+1): 4 | for j in range(0, height+1): 5 | if (j == counter or j == height - counter): 6 | print("X", end="") 7 | else: 8 | print(end=" ") 9 | counter = counter + 1 10 | print() 11 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolicpattern169.py: -------------------------------------------------------------------------------- 1 | n=max=5 2 | symbol_arr=[4,3,5,1,2] 3 | for i in range(max): 4 | for j in range(n): 5 | if symbol_arr[j] >= max-i: 6 | print(' # ',end='') 7 | else: 8 | print(' ', end='') 9 | print(end='\n') 10 | for i in range(n): 11 | print([i+1],end='') -------------------------------------------------------------------------------- /Symbol Patterns/symbolicpattern42.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | counter = 1 4 | for i in range(1, n+1): 5 | for j in range(0, counter): 6 | if j % 2 != 0: 7 | print("*", end=" ") 8 | else: 9 | print(i, end=" ") 10 | counter += 1 11 | print() 12 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern1.py: -------------------------------------------------------------------------------- 1 | """ 2 | In this question, we simply have to print a n*n grid 3 | We can do this by using a single for loop 4 | """ 5 | size = 5 # n*n grid 6 | for i in range(size): 7 | print("*"*size) 8 | 9 | """ 10 | OUTPUT: 11 | 12 | ***** 13 | ***** 14 | ***** 15 | ***** 16 | ***** 17 | """ -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern206.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | counter = height - 1 3 | for i in range(0, height): 4 | for j in range(0, height): 5 | if i == 0 or i == height - 1 or j == counter: 6 | print("*", end="") 7 | else: 8 | print(end=" ") 9 | counter = counter - 1 10 | print() 11 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern72.py: -------------------------------------------------------------------------------- 1 | alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 2 | print("Enter the no of rows: ") 3 | n = int(input()) 4 | 5 | for i in range(0, n): 6 | for j in range(0,i+1): 7 | if(i%2==0): 8 | print(alpha[i],end=" ") 9 | else: 10 | print(i+1,end=" ") 11 | print() 12 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern73.py: -------------------------------------------------------------------------------- 1 | alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 2 | print("Enter the no of rows: ") 3 | n = int(input()) 4 | 5 | for i in range(0, n): 6 | for j in range(0,i+1): 7 | if(i%2!=0): 8 | print(alpha[i],end=" ") 9 | else: 10 | print(i+1,end=" ") 11 | print() 12 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern74.py: -------------------------------------------------------------------------------- 1 | alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 2 | print("Enter the no of rows: ") 3 | n = int(input()) 4 | 5 | for i in range(0, n): 6 | for j in range(0,i+1): 7 | if(i%2==0): 8 | print(alpha[i],end=" ") 9 | else: 10 | print(j+1,end=" ") 11 | print() 12 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern75.py: -------------------------------------------------------------------------------- 1 | alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 2 | print("Enter the no of rows: ") 3 | n = int(input()) 4 | 5 | for i in range(0, n): 6 | for j in range(0,i+1): 7 | if(i%2!=0): 8 | print(alpha[j],end=" ") 9 | else: 10 | print(j+1,end=" ") 11 | print() 12 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern77.py: -------------------------------------------------------------------------------- 1 | alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 2 | print("Enter the no of rows: ") 3 | n = int(input()) 4 | 5 | for i in range(0, n): 6 | for j in range(0,n-i): 7 | if(i%2==0): 8 | print(alpha[j],end=" ") 9 | else: 10 | print(j+1,end=" ") 11 | print() 12 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern79.py: -------------------------------------------------------------------------------- 1 | alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 2 | print("Enter the no of rows: ") 3 | n = int(input()) 4 | 5 | for i in range(0, n): 6 | for j in range(0,n-i): 7 | if(i%2!=0): 8 | print(alpha[j],end=" ") 9 | else: 10 | print(j+1,end=" ") 11 | print() 12 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern48.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows:") 2 | n = int(input()) 3 | a = 0 4 | for i in range(0, n): 5 | for j in range(0, i+1): 6 | if j == 1 or j == 2: 7 | a = 1 8 | elif j > 2: 9 | a = a + 1 10 | print(a, end=" ") 11 | counter = 1 12 | print() 13 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern108.py: -------------------------------------------------------------------------------- 1 | n=5 2 | for i in range (n): 3 | for j in range (i,n-1): 4 | print(' ', end='') 5 | for k in range (i+1): 6 | print('* ', end='') 7 | for l in range (i+1, n): 8 | print(' ', end=' ') 9 | for m in range (i+1): 10 | print('* ', end='') 11 | print() 12 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern76.py: -------------------------------------------------------------------------------- 1 | alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 2 | print("Enter the no of rows: ") 3 | n = int(input()) 4 | 5 | for i in range(0, n): 6 | for j in range(0,n-i): 7 | if(i%2==0): 8 | print(alpha[n-i-1],end=" ") 9 | else: 10 | print(n-i,end=" ") 11 | print() 12 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern78.py: -------------------------------------------------------------------------------- 1 | alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 2 | print("Enter the no of rows: ") 3 | n = int(input()) 4 | 5 | for i in range(0, n): 6 | for j in range(0,n-i): 7 | if(i%2!=0): 8 | print(alpha[n-i-1],end=" ") 9 | else: 10 | print(n-i,end=" ") 11 | print() 12 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern113.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | count = n 4 | for i in range(n): 5 | print(" "*i + str(count)*(2*(n-i)-1)) 6 | count-=1 7 | 8 | # OUTPUT 9 | # Enter the number of rows: 10 | # 5 11 | # 555555555 12 | # 4444444 13 | # 33333 14 | # 222 15 | # 1 16 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern166.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | c = 1 5 | 6 | for j in range(1,i*2): 7 | print(c,end=" ") 8 | c += 1 9 | 10 | print() 11 | 12 | # Sample Input :- 4 13 | # Output :- 14 | # 1 15 | # 1 2 3 16 | # 1 2 3 4 5 17 | # 1 2 3 4 5 6 7 18 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern27.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | m = height 3 | 4 | for i in range(1,height+1) : 5 | 6 | for j in range(1, i+1): 7 | print(m,end = " ") 8 | m-=1 9 | 10 | print() 11 | 12 | # Sample Input :- 5 13 | # Output :- 14 | # 5 15 | # 4 4 16 | # 3 3 3 17 | # 2 2 2 2 18 | # 1 1 1 1 1 19 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern5.py: -------------------------------------------------------------------------------- 1 | # Numeric Pattern 5 2 | 3 | """ 4 | 5 | 1 2 3 4 5 6 | 6 7 8 9 10 7 | 11 12 13 14 15 8 | 16 17 18 19 20 9 | 21 22 23 24 25 10 | 11 | """ 12 | i = 0 13 | nums = list(range(1, 26)) 14 | for _ in range(5): 15 | j = i + 5 16 | row = " ".join(map(str, nums[i:j])) 17 | print(row) 18 | i = j 19 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern59.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows and starting number respectively: ") 2 | n, i = map(int, input().split()) 3 | a = i 4 | b = n 5 | for j in range(0, n): 6 | for k in range(b, 0, -1): 7 | print(i, end=" ") 8 | i = i - 1 9 | i = a + 1 10 | a = a + 1 11 | b = b - 1 12 | print() -------------------------------------------------------------------------------- /Symbol Patterns/symbolicpattern43.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | counter = n 4 | for i in range(0, n): 5 | for j in range(0, counter): 6 | if i % 2 != 0: 7 | print("*", end=" ") 8 | else: 9 | print("#", end=" ") 10 | counter = counter - 1 11 | print() 12 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolicpattern44.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | counter = n 4 | for i in range(0, n): 5 | for j in range(0, counter): 6 | if j % 2 != 0: 7 | print("*", end=" ") 8 | else: 9 | print("#", end=" ") 10 | counter = counter - 1 11 | print() 12 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolicpattern46.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | counter = n 4 | for i in range(0, n): 5 | for j in range(1, counter+1): 6 | if i % 2 != 0: 7 | print("*", end=" ") 8 | else: 9 | print(j, end=" ") 10 | counter = counter - 1 11 | print() 12 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolicpattern47.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | counter = n 4 | for i in range(0, n): 5 | for j in range(1, counter+1): 6 | if j % 2 == 0: 7 | print("*", end=" ") 8 | else: 9 | print(j, end=" ") 10 | counter = counter - 1 11 | print() 12 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern107.py: -------------------------------------------------------------------------------- 1 | n = 4 2 | for i in range (n): 3 | for j in range (i, n-1): 4 | print(' ', end='') 5 | for k in range (2*i+1): 6 | print('*', end='') 7 | for l in range (i+1, n): 8 | print(' ', end=' ') 9 | for m in range (2*i+1): 10 | print('*', end='') 11 | print() 12 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern109.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | for i in range (n): 3 | for j in range (1,n+1-i): 4 | print(j, end='') 5 | for k in range (2*i+1): 6 | print('*' ,end='') 7 | for l in range (n-i,0,-1): 8 | print(l, end='') 9 | print() 10 | for m in range (2*n+1): 11 | print('*', end='') 12 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern144.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | for i in range(0,height) : 3 | print("*",end="") 4 | for j in range(0,height) : 5 | if ( (i == 0 or i == height - 1) or (i == height // 2 and j <= height // 2) ): 6 | print("*",end="") 7 | else : 8 | continue 9 | print() -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern170.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | for i in range(0,height) : 3 | print("E",end="") 4 | for j in range(0,height) : 5 | if ( (i == 0 or i == height - 1) or (i == height // 2 and j <= height // 2) ): 6 | print("E",end="") 7 | else : 8 | continue 9 | print() -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern15.py: -------------------------------------------------------------------------------- 1 | # Numeric Pattern 15 2 | 3 | """ 4 | Desired pattern: 5 | 6 | 1 2 3 4 5 7 | 2 3 4 5 6 8 | 3 4 5 6 7 9 | 4 5 6 7 8 10 | 5 6 7 8 9 11 | 12 | """ 13 | 14 | for i in range(1, 6): 15 | print(i, end=" ") 16 | for _ in range(4): 17 | print(i + 1, end=" ") 18 | i += 1 19 | print() 20 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern171.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | x = 1 3 | 4 | for i in range(1,height): 5 | 6 | for j in range(1,i+1): 7 | 8 | print(x,end="# ") 9 | x += 1 10 | 11 | print() 12 | 13 | # Sample Input :- 5 14 | # Output :- 15 | # 1# 16 | # 2# 3# 17 | # 4# 5# 6# 18 | # 7# 8# 9# 10# 19 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern39.py: -------------------------------------------------------------------------------- 1 | def pypart2(n): 2 | counter = 1 3 | flag=n-1 4 | for i in range(0, n): 5 | for j in range(0, i+1): 6 | print(counter-j, end=" ") 7 | counter=counter+flag 8 | flag = flag-1 9 | print("\r") 10 | 11 | print("Enter the number of rows: ") 12 | n = int(input()) 13 | pypart2(n) 14 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern60.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows and starting number respectively: ") 2 | n, i = map(int, input().split()) 3 | a = i 4 | b = n 5 | for j in range(0, n): 6 | for k in range(b, 0, -1): 7 | print(i, end=" ") 8 | i = i + 1 9 | i = a - 1 10 | a = a - 1 11 | b = b - 1 12 | print() 13 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern64.py: -------------------------------------------------------------------------------- 1 | 2 | print("Enter the number of rows:") 3 | n = int(input()) 4 | count = n 5 | flag = n 6 | for i in range(0,n): 7 | minus = n-1 8 | count=flag 9 | for j in range(0,n-i): 10 | print(count,end=" ") 11 | count+=minus 12 | minus=minus-1 13 | flag=flag-1 14 | print() 15 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolicpattern20.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows: ") 2 | a = int(input()) 3 | counter = 1 4 | for i in range(0, a): 5 | for j in range(0, a): 6 | if j in range(0, counter): 7 | print(chr(i+65), end=" ") 8 | else: 9 | print("*", end=" ") 10 | counter = counter + 1 11 | print() 12 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolicpattern21.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows: ") 2 | a = int(input()) 3 | counter = 1 4 | for i in range(0, a): 5 | for j in range(0, a): 6 | if j in range(0, counter): 7 | print(chr(j+65), end=" ") 8 | else: 9 | print("*", end=" ") 10 | counter = counter + 1 11 | print() 12 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolicpattern48.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | counter = n 4 | for i in range(n, 0, -1): 5 | for j in range(1, counter+1): 6 | if j % 2 == 0: 7 | print("*", end=" ") 8 | else: 9 | print(i, end=" ") 10 | counter = counter - 1 11 | print() 12 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern154.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows:") 2 | n = int(input()) 3 | counter = 2 4 | iterations = 0 5 | for i in range(0, n): 6 | for j in range(0, counter): 7 | print("*", end=" ") 8 | iterations = iterations + 1 9 | if iterations % 2 == 0: 10 | counter = counter + 2 11 | print() 12 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern156.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows:") 2 | n = int(input()) 3 | counter = n 4 | iterations = 0 5 | for i in range(0, n): 6 | for j in range(0, counter): 7 | print("*", end=" ") 8 | iterations = iterations + 1 9 | if iterations % 2 == 0: 10 | counter = counter - 2 11 | print() 12 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern158.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows:") 2 | n = int(input()) 3 | counter = 1 4 | iterations = 0 5 | for i in range(0, n): 6 | for j in range(0, counter): 7 | print("*", end=" ") 8 | iterations = iterations + 1 9 | if iterations % 2 == 0: 10 | counter = counter + 1 11 | print() 12 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern191.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | half = height // 2 3 | dummy = half 4 | for i in range(0, height): 5 | print("*", end="") 6 | for j in range(0, half+1): 7 | if (j == abs(dummy)): 8 | print("*", end="") 9 | else: 10 | print(end=" ") 11 | print() 12 | dummy = dummy - 1 13 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern159.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | for i in range(0,height) : 3 | for j in range(0,height) : 4 | if ( i == 0 ): 5 | print("*",end="") 6 | elif ( j == height // 2 ) : 7 | print("*",end="") 8 | else : 9 | print(end=" ") 10 | print() -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern185.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | for i in range(0,height) : 3 | for j in range(0,height) : 4 | if ( i == 0 ): 5 | print("T",end="") 6 | elif ( j == height // 2 ) : 7 | print("T",end="") 8 | else : 9 | print(end=" ") 10 | print() -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern222.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(0,height): 4 | print(i,end=" ") 5 | 6 | for j in range(0,i): 7 | print("*",end=" ") 8 | 9 | print() 10 | 11 | # Sample Input :- 6 12 | # Output :- 13 | # 0 14 | # 1 * 15 | # 2 * * 16 | # 3 * * * 17 | # 4 * * * * 18 | # 5 * * * * * 19 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolicpattern26.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows: ") 2 | a = int(input()) 3 | counter = 0 4 | for i in range(a, 0, -1): 5 | for j in range(0, a): 6 | if j in range(counter, a): 7 | print(chr(i+64), end=" ") 8 | else: 9 | print("*", end=" ") 10 | counter = counter + 1 11 | print() 12 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern150.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | half = height // 2 3 | dummy = half 4 | for i in range(0, height): 5 | print("*", end="") 6 | for j in range(0, half+1): 7 | if (j == abs(dummy)): 8 | print("*", end="") 9 | else: 10 | print(end=" ") 11 | print() 12 | dummy = dummy - 1 13 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern176.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | half = height // 2 3 | dummy = half 4 | for i in range(0, height): 5 | print("K", end="") 6 | for j in range(0, half+1): 7 | if (j == abs(dummy)): 8 | print("K", end="") 9 | else: 10 | print(end=" ") 11 | print() 12 | dummy = dummy - 1 13 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern13.py: -------------------------------------------------------------------------------- 1 | # Numeric Pattern 12 2 | 3 | """ 4 | Desired Output: 5 | 6 | 5 10 15 20 25 7 | 4 9 14 19 24 8 | 3 8 13 18 23 9 | 2 7 12 17 22 10 | 1 6 11 16 21 11 | """ 12 | 13 | x = 5 14 | for i in range(5, 0, -1): 15 | j = i 16 | for _ in range(5): 17 | print(j, end=" ") 18 | j += x 19 | print() 20 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern38.py: -------------------------------------------------------------------------------- 1 | 2 | print("Enter the number of rows:") 3 | n = int(input()) 4 | column_count=0 5 | for i in range(0,n): 6 | row_count = column_count+1 7 | for j in range(0,i+1): 8 | print(row_count,end=" ") 9 | row_count=row_count-(n-j-i) 10 | column_count=column_count+n-i 11 | print() 12 | 13 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern6.py: -------------------------------------------------------------------------------- 1 | # Numeric Pattern 6 2 | 3 | """ 4 | 5 | 1 3 5 7 9 6 | 11 13 15 17 19 7 | 21 23 25 27 29 8 | 31 33 35 37 39 9 | 41 43 45 47 49 10 | 11 | """ 12 | 13 | i = 0 14 | nums = list(range(1, 50, 2)) 15 | for _ in range(5): 16 | j = i + 5 17 | row = " ".join(map(str, nums[i:j])) 18 | print(row) 19 | i = j 20 | -------------------------------------------------------------------------------- /String Patterns/stringpattern11.py: -------------------------------------------------------------------------------- 1 | print('Enter a string') 2 | pattern_string = input() 3 | reverse = pattern_string[::-1] 4 | str_length = len(pattern_string) 5 | for i in range (str_length) : 6 | for j in range (i, str_length-1) : 7 | print(' ', end =' ') 8 | for ch in reverse [0:i+1] : 9 | print(ch, end =' ') 10 | print(end ='\n') 11 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolicpattern24.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows: ") 2 | a = int(input()) 3 | counter = 0 4 | for i in range(0, a): 5 | for j in range(a, 0, -1): 6 | if j in range(a, counter-1, -1): 7 | print("*", end=" ") 8 | else: 9 | print(chr(i+65), end=" ") 10 | counter = counter + 1 11 | print() 12 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolicpattern25.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows: ") 2 | a = int(input()) 3 | counter = 1 4 | for i in range(0, a): 5 | for j in range(a, 0, -1): 6 | if j in range(a, counter, -1): 7 | print("*", end=" ") 8 | else: 9 | print(chr(j+64), end=" ") 10 | counter = counter + 1 11 | print() 12 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern202.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | width = 2*height - 1 3 | counter = 0 4 | for i in range(0, height): 5 | for j in range(0, width + 1): 6 | if j == counter or j == width - counter - 1: 7 | print("*", end="") 8 | else: 9 | print(end=" ") 10 | 11 | counter = counter + 1 12 | print() 13 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern161.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | width = 2*height-1 3 | counter = 0 4 | for i in range(0, height): 5 | for j in range(0, width+1): 6 | if (j == counter or j == width - counter - 1): 7 | print("*", end="") 8 | else: 9 | print(end=" ") 10 | 11 | counter = counter + 1 12 | print() 13 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern165.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | counter = height - 1 3 | for i in range(0, height): 4 | for j in range(0, height): 5 | if (i == 0 or i == height - 1 or j == counter): 6 | print("*", end="") 7 | else: 8 | print(end=" ") 9 | counter = counter - 1 10 | print() 11 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern187.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | width = 2*height-1 3 | counter = 0 4 | for i in range(0, height): 5 | for j in range(0, width+1): 6 | if (j == counter or j == width - counter - 1): 7 | print("V", end="") 8 | else: 9 | print(end=" ") 10 | 11 | counter = counter + 1 12 | print() 13 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern191.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | counter = height - 1 3 | for i in range(0, height): 4 | for j in range(0, height): 5 | if (i == 0 or i == height - 1 or j == counter): 6 | print("Z", end="") 7 | else: 8 | print(end=" ") 9 | counter = counter - 1 10 | print() 11 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern7.py: -------------------------------------------------------------------------------- 1 | # Numeric Pattern 7 2 | 3 | """ 4 | 5 | 2 4 6 8 10 6 | 12 14 16 18 20 7 | 22 24 26 28 30 8 | 32 34 36 38 40 9 | 42 44 46 48 50 10 | 11 | """ 12 | 13 | i = 0 14 | nums = list(range(2, 52, 2)) 15 | 16 | for _ in range(5): 17 | j = i + 5 18 | row = " ".join(map(str, nums[i:j])) 19 | print(row) 20 | i = j 21 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern8.py: -------------------------------------------------------------------------------- 1 | # Numeric Pattern 8 2 | 3 | """ 4 | 5 | 1 2 3 4 5 6 | 2 4 6 8 10 7 | 3 6 9 12 15 8 | 4 8 12 16 20 9 | 5 10 15 20 25 10 | 11 | """ 12 | 13 | def pattern(rows): 14 | for x in range(1, rows + 1): 15 | row = " ".join(map(str, [x * i for i in range(1, rows + 1)])) 16 | print(row) 17 | 18 | pattern(5) 19 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern39.py: -------------------------------------------------------------------------------- 1 | n = int(input("Enter the number of rows: ")) 2 | spaces = 1 3 | counter = n + 4 4 | for i in range(n, 0, -1): 5 | for k in range(0, spaces): 6 | print(" ", end=" ") 7 | for j in range(1, counter+1): 8 | print(j, end=" ") 9 | counter = counter - 2 10 | spaces = spaces + 1 11 | print() 12 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolicpattern22.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows: ") 2 | a = int(input()) 3 | counter = 0 4 | for i in range(a, 0, -1): 5 | for j in range(a, 0, -1): 6 | if j in range(a, counter, -1): 7 | print(chr(i+64), end=" ") 8 | else: 9 | print("*", end=" ") 10 | counter = counter + 1 11 | print() 12 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern189.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | for i in range(0,height) : 3 | for j in range(0,height) : 4 | if ( i == 0 or i == height - 1 ): 5 | print("*",end="") 6 | elif ( j == height // 2 ) : 7 | print("*",end="") 8 | else : 9 | print(end=" ") 10 | print() -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern148.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | for i in range(0, height): 3 | for j in range(0, height): 4 | if (i == 0 or i == height - 1): 5 | print("*", end="") 6 | elif (j == height // 2): 7 | print("*", end="") 8 | else: 9 | print(end=" ") 10 | print() 11 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern174.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | for i in range(0, height): 3 | for j in range(0, height): 4 | if (i == 0 or i == height - 1): 5 | print("I", end="") 6 | elif (j == height // 2): 7 | print("I", end="") 8 | else: 9 | print(end=" ") 10 | print() 11 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern11.py: -------------------------------------------------------------------------------- 1 | # Numeric Pattern 11 2 | 3 | """ 4 | 5 | 1 6 11 16 21 6 | 2 7 12 17 22 7 | 3 8 13 18 23 8 | 4 9 14 19 24 9 | 5 10 15 20 25 10 | 11 | """ 12 | 13 | for i in range(1, 6): 14 | print(i, end=" ") 15 | for _ in range(4): 16 | x = i + 5 17 | print(x, end=" ") 18 | i = x 19 | print() 20 | 21 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern45.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows and starting number respectively: ") 2 | n, i = map(int, input().split()) 3 | a = 3 4 | b = i 5 | for x in range(0, n): 6 | for j in range(0, x+1): 7 | if x > 0: 8 | i = b + a 9 | a = a + 2 10 | b = i 11 | print(i, end=" ") 12 | print() 13 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern2.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | spaces = n 4 | counter = 1 5 | for i in range(0, n): 6 | for k in range(0, spaces): 7 | print(" ", end="") 8 | for j in range(1, counter+1): 9 | print(i+1, end=" ") 10 | counter = counter + 1 11 | print() 12 | spaces = spaces - 1 13 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern3.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | spaces = n 4 | counter = 1 5 | for i in range(0, n): 6 | for k in range(0, spaces): 7 | print(" ", end="") 8 | for j in range(0, counter): 9 | print(j+1, end=" ") 10 | counter = counter + 1 11 | print() 12 | spaces = spaces - 1 13 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern6.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | spaces = 1 4 | counter = n 5 | for i in range(0, n): 6 | for k in range(0, spaces): 7 | print(" ", end="") 8 | for j in range(0, counter): 9 | print("*", end=" ") 10 | counter = counter - 1 11 | print() 12 | spaces = spaces + 1 13 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern7.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | spaces = 1 4 | counter = n 5 | for i in range(0, n): 6 | for k in range(0, spaces): 7 | print(" ", end="") 8 | for j in range(0, counter): 9 | print(counter, end=" ") 10 | counter = counter - 1 11 | print() 12 | spaces = spaces + 1 13 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern8.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | spaces = 1 4 | counter = n 5 | for i in range(0, n): 6 | for k in range(0, spaces): 7 | print(" ", end="") 8 | for j in range(counter, 0, -1): 9 | print(j, end=" ") 10 | counter = counter - 1 11 | print() 12 | spaces = spaces + 1 13 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolicpattern45.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | counter = n 4 | c = n 5 | for i in range(0, n): 6 | for j in range(0, counter): 7 | if i % 2 != 0: 8 | print("*", end=" ") 9 | else: 10 | print(c, end=" ") 11 | counter = counter - 1 12 | c = c - 1 13 | print() 14 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern16.py: -------------------------------------------------------------------------------- 1 | # Numeric Pattern 16 2 | 3 | """ 4 | Desired Pattern: 5 | 6 | 1 3 5 7 9 7 | 3 5 7 9 11 8 | 5 7 9 11 13 9 | 7 9 11 13 15 10 | 9 11 13 15 17 11 | 12 | """ 13 | 14 | for i in range(1, 10, 2): 15 | print(i, end=" ") 16 | for _ in range(4): 17 | print(i + 2, end = " ") 18 | i += 2 19 | print() 20 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern11.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | spaces = 1 4 | counter = n 5 | for i in range(0, n): 6 | for k in range(0, spaces): 7 | print(" ", end="") 8 | for j in range(0, counter): 9 | print(chr(j+65), end=" ") 10 | counter = counter - 1 11 | print() 12 | spaces = spaces + 1 13 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern4.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | spaces = n 4 | counter = 1 5 | for i in range(0, n): 6 | for k in range(0, spaces): 7 | print(" ", end="") 8 | for j in range(0, counter): 9 | print(chr(i+65), end=" ") 10 | counter = counter + 1 11 | print() 12 | spaces = spaces - 1 13 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern40.py: -------------------------------------------------------------------------------- 1 | n = int(input("Enter the number of rows: ")) 2 | spaces = 1 3 | counter = n + 4 4 | for i in range(n, 0, -1): 5 | for k in range(0, spaces): 6 | print(" ", end=" ") 7 | for j in range(1, counter+1): 8 | print(chr(i+64), end=" ") 9 | counter = counter - 2 10 | spaces = spaces + 1 11 | print() 12 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern42.py: -------------------------------------------------------------------------------- 1 | n = int(input("Enter the number of rows: ")) 2 | spaces = 1 3 | counter = n + 4 4 | for i in range(n, 0, -1): 5 | for k in range(0, spaces): 6 | print(" ", end=" ") 7 | for j in range(1, counter+1): 8 | print(chr(j+64), end=" ") 9 | counter = counter - 2 10 | spaces = spaces + 1 11 | print() 12 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern5.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | spaces = n 4 | counter = 1 5 | for i in range(0, n): 6 | for k in range(0, spaces): 7 | print(" ", end="") 8 | for j in range(0, counter): 9 | print(chr(j+65), end=" ") 10 | counter = counter + 1 11 | print() 12 | spaces = spaces - 1 13 | -------------------------------------------------------------------------------- /Series Patterns/seriespattern9.py: -------------------------------------------------------------------------------- 1 | """ 2 | The sequence which is generated from a pattern of dots which form a triangle is known as Triangular Number Sequence. 3 | """ 4 | 5 | n = 5 # size 6 | 7 | for x in range(1, n + 1): 8 | num = (x * (x + 1)) // 2 9 | print(" " + str(num), end="") 10 | 11 | """ 12 | OUTPUT: 13 | 14 | 1 3 6 10 15 15 | 16 | """ -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern10.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | spaces = 1 4 | counter = n 5 | for i in range(0, n): 6 | for k in range(0, spaces): 7 | print(" ", end="") 8 | for j in range(counter, 0, -1): 9 | print(chr(j+64), end=" ") 10 | counter = counter - 1 11 | print() 12 | spaces = spaces + 1 13 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern12.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | spaces = n + (n - 1) 4 | counter = 1 5 | for i in range(0, n): 6 | for k in range(0, spaces): 7 | print(" ", end="") 8 | for j in range(0, counter): 9 | print("*", end=" ") 10 | counter = counter + 2 11 | print() 12 | spaces = spaces - 2 13 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern13.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | spaces = n + (n - 1) 4 | counter = 1 5 | for i in range(0, n): 6 | for k in range(0, spaces): 7 | print(" ", end="") 8 | for j in range(0, counter): 9 | print(i+1, end=" ") 10 | counter = counter + 2 11 | print() 12 | spaces = spaces - 2 13 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern15.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | spaces = n + (n - 1) 4 | counter = 1 5 | for i in range(0, n): 6 | for k in range(0, spaces): 7 | print(" ", end="") 8 | for j in range(0, counter): 9 | print(j+1, end=" ") 10 | counter = counter + 2 11 | print() 12 | spaces = spaces - 2 13 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern16.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | spaces = n + (n - 1) 4 | counter = 1 5 | for i in range(0, n): 6 | for k in range(0, spaces): 7 | print(" ", end="") 8 | for j in range(counter, 0, -1): 9 | print(j, end=" ") 10 | counter = counter + 2 11 | print() 12 | spaces = spaces - 2 13 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern17.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | spaces = n + (n - 1) 4 | counter = 1 5 | for i in range(n, 0, -1): 6 | for k in range(0, spaces): 7 | print(" ", end="") 8 | for j in range(0, counter): 9 | print(i, end=" ") 10 | counter = counter + 2 11 | print() 12 | spaces = spaces - 2 13 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern36.py: -------------------------------------------------------------------------------- 1 | n = int(input("Enter the number of rows: ")) 2 | spaces = 1 3 | counter = n + 4 4 | for i in range(1, n + 1): 5 | b = i 6 | for k in range(0, spaces): 7 | print(" ", end=" ") 8 | for j in range(0, counter): 9 | print("*", end=" ") 10 | counter = counter - 2 11 | spaces = spaces + 1 12 | print() 13 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern37.py: -------------------------------------------------------------------------------- 1 | n = int(input("Enter the number of rows: ")) 2 | spaces = 1 3 | counter = n + 4 4 | for i in range(n, 0, -1): 5 | b = i 6 | for k in range(0, spaces): 7 | print(" ", end=" ") 8 | for j in range(0, counter): 9 | print(i, end=" ") 10 | counter = counter - 2 11 | spaces = spaces + 1 12 | print() 13 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern41.py: -------------------------------------------------------------------------------- 1 | n = int(input("Enter the number of rows: ")) 2 | spaces = 1 3 | counter = n + 4 4 | for i in range(n, 0, -1): 5 | for k in range(0, spaces): 6 | print(" ", end=" ") 7 | for j in range(1, counter+1): 8 | print(chr(counter+64), end=" ") 9 | counter = counter - 2 10 | spaces = spaces + 1 11 | print() 12 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern181.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | width = 2 * height - 1 3 | n = width // 2 4 | for i in range(0, height): 5 | for j in range(0, width + 1): 6 | if j == n or j == (width - n) or (i == (height // 2) and n < j < (width - n)): 7 | print("*", end="") 8 | else: 9 | print(end=" ") 10 | print() 11 | n = n - 1 12 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern205.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | counter = 0 3 | for i in range(0, height): 4 | for j in range(0, height + 1): 5 | if j == counter or j == height - counter and i <= height // 2: 6 | print("*", end="") 7 | else: 8 | print(end=" ") 9 | print() 10 | if i < height // 2: 11 | counter = counter + 1 12 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern14.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | spaces = n + (n - 1) 4 | counter = 1 5 | for i in range(0, n): 6 | for k in range(0, spaces): 7 | print(" ", end="") 8 | for j in range(0, counter): 9 | print(counter, end=" ") 10 | counter = counter + 2 11 | print() 12 | spaces = spaces - 2 13 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern9.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | spaces = 1 4 | counter = n 5 | for i in range(0, n): 6 | for k in range(0, spaces): 7 | print(" ", end="") 8 | for j in range(counter, 0, -1): 9 | print(chr(counter+64), end=" ") 10 | counter = counter - 1 11 | print() 12 | spaces = spaces + 1 13 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolicpattern33.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows: ") 2 | a = int(input()) 3 | counter = 1 4 | n = 1 5 | for i in range(0, a): 6 | for j in range(0, n): 7 | if j % 2 == 1: 8 | print("*", end=" ") 9 | else: 10 | print(counter, end=" ") 11 | counter += 1 12 | counter = 1 13 | n += 2 14 | print() 15 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern140.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | width = 2 * height - 1 3 | n = width // 2 4 | for i in range(0, height): 5 | for j in range(0, width + 1): 6 | if j == n or j == (width - n) or (i == (height // 2) and n < j < (width - n)): 7 | print("*", end="") 8 | else: 9 | print(end=" ") 10 | print() 11 | n = n - 1 12 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern166.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | width = 2 * height - 1 3 | n = width // 2 4 | for i in range(0, height): 5 | for j in range(0, width + 1): 6 | if j == n or j == (width - n) or (i == (height // 2) and n < j < (width - n)): 7 | print("A", end="") 8 | else: 9 | print(end=" ") 10 | print() 11 | n = n - 1 12 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern29.py: -------------------------------------------------------------------------------- 1 | n = int(input("Enter the number of rows: ")) 2 | spaces = n + (n - 1) 3 | counter = 1 4 | for i in range(1, n + 1): 5 | b = i 6 | for k in range(0, spaces): 7 | print(" ", end="") 8 | for j in range(0, counter): 9 | print(chr(i+64), end=" ") 10 | counter = counter + 2 11 | spaces = spaces - 2 12 | print() 13 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern31.py: -------------------------------------------------------------------------------- 1 | n = int(input("Enter the number of rows: ")) 2 | spaces = n + (n - 1) 3 | counter = 1 4 | for i in range(1, n + 1): 5 | b = i 6 | for k in range(0, spaces): 7 | print(" ", end="") 8 | for j in range(0, counter): 9 | print(chr(j+65), end=" ") 10 | counter = counter + 2 11 | spaces = spaces - 2 12 | print() 13 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolicpattern27.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows: ") 2 | a = int(input()) 3 | counter = 0 4 | for i in range(0, a): 5 | b = 0 6 | for j in range(0, a): 7 | if j in range(counter, a): 8 | print(chr(b+69), end=" ") 9 | else: 10 | print("*", end=" ") 11 | b = b - 1 12 | counter = counter + 1 13 | print() 14 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern115.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | for i in range(n): 4 | count = 1 5 | for j in range(0,2*(n-i)-1): 6 | print(count,end=""); 7 | count+=1 8 | 9 | print() 10 | 11 | # OUTPUT 12 | # Enter the number of rows: 13 | # 5 14 | # 123456789 15 | # 1234567 16 | # 12345 17 | # 123 18 | # 1 19 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern1.py: -------------------------------------------------------------------------------- 1 | '''Desired Pattern 2 | * 3 | * * 4 | * * * 5 | * * * * 6 | * * * * * 7 | ''' 8 | num=int(input("Enter the number of rows:")) 9 | for i in range(0,num): 10 | for j in range(0, num-i-1): 11 | print(end=" ") 12 | for j in range(0, i+1): 13 | print("*",end=" ") 14 | print() 15 | 16 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern93.py: -------------------------------------------------------------------------------- 1 | num = int(input("Enter the Number: ")) 2 | 3 | for i in range(1, num+1): 4 | for j in range(0, i): 5 | print(" ", end="") 6 | 7 | for j in range(1, (num*2 - (2*i - 1))+1): 8 | if i == 1 or j == 1 or j ==(num*2 -(2*i-1)): 9 | print("*", end="") 10 | else: 11 | print(" ", end="") 12 | print() -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern143.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,i+1): 6 | print(1,end=" ") 7 | 8 | for j in range(i,height): 9 | print(0,end=" ") 10 | 11 | print() 12 | 13 | # Sample Input :- 5 14 | # Output :- 15 | # 1 0 0 0 0 16 | # 1 1 0 0 0 17 | # 1 1 1 0 0 18 | # 1 1 1 1 0 19 | # 1 1 1 1 1 20 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern145.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(0,height): 4 | 5 | for j in range(i,0,-1): 6 | print(j,end=" ") 7 | 8 | for j in range(0,height-i): 9 | print(j,end=" ") 10 | 11 | print() 12 | 13 | # Sample Input :- 5 14 | # Output :- 15 | # 0 1 2 3 4 16 | # 1 0 1 2 3 17 | # 2 1 0 1 2 18 | # 3 2 1 0 1 19 | # 4 3 2 1 0 20 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern151.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,height-i+2): 6 | print(j,end=" ") 7 | 8 | for j in range(1,i): 9 | print("*",end=" ") 10 | 11 | print() 12 | 13 | # Sample Input :- 5 14 | # Output :- 15 | # 1 2 3 4 5 16 | # 1 2 3 4 * 17 | # 1 2 3 * * 18 | # 1 2 * * * 19 | # 1 * * * * 20 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern176.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(height,0,-1): 4 | 5 | for j in range(1,height+1): 6 | 7 | print(j,end=" ") 8 | 9 | height-=2 10 | print() 11 | 12 | # Sample Input :- 9 13 | # Output :- 14 | # 1 2 3 4 5 6 7 8 9 15 | # 1 2 3 4 5 6 7 16 | # 1 2 3 4 5 17 | # 1 2 3 18 | # 1 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern194.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | count= 0 3 | for i in range(0, height): 4 | print("*", end="") 5 | for j in range(0, height+1): 6 | if (j == height): 7 | print("*", end="") 8 | elif (j == count): 9 | print("*", end="") 10 | else: 11 | print(end=" ") 12 | count = count + 1 13 | print() 14 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern2.py: -------------------------------------------------------------------------------- 1 | """ 2 | In this question, we have to print stars from 1 to n 3 | We can use a for loop starting from 1 (because we start with 1 star) which goes till n+1 (because upper limit is ignored) 4 | """ 5 | n = 5 # size 6 | for i in range(1, n+1): 7 | print("*"*i) 8 | 9 | """ 10 | OUTPUT: 11 | 12 | * 13 | ** 14 | *** 15 | **** 16 | ***** 17 | """ -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern153.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | counter = 0 3 | for i in range(0, height): 4 | print("*", end="") 5 | for j in range(0, height+1): 6 | if (j == height): 7 | print("*", end="") 8 | elif (j == counter): 9 | print("*", end="") 10 | else: 11 | print(end=" ") 12 | counter = counter + 1 13 | print() 14 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern179.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | counter = 0 3 | for i in range(0, height): 4 | print("N", end="") 5 | for j in range(0, height+1): 6 | if (j == height): 7 | print("N", end="") 8 | elif (j == counter): 9 | print("N", end="") 10 | else: 11 | print(end=" ") 12 | counter = counter + 1 13 | print() 14 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern149.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,i+1): 6 | print(j,end=" ") 7 | 8 | for j in range(height-i,0,-1): 9 | print("*",end=" ") 10 | 11 | print() 12 | 13 | # Sample Input :- 5 14 | # Output :- 15 | # 1 * * * * 16 | # 1 2 * * * 17 | # 1 2 3 * * 18 | # 1 2 3 4 * 19 | # 1 2 3 4 5 20 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern152.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,height-i+1): 6 | print("*",end=" ") 7 | 8 | for j in range(i,0,-1): 9 | print(i,end=" ") 10 | 11 | print() 12 | 13 | # Sample Input :- 5 14 | # Output :- 15 | # * * * * 1 16 | # * * * 2 2 17 | # * * 3 3 3 18 | # * 4 4 4 4 19 | # 5 5 5 5 5 20 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern153.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,height-i+1): 6 | print("*",end=" ") 7 | 8 | for j in range(i,0,-1): 9 | print(j,end=" ") 10 | 11 | print() 12 | 13 | # Sample Input :- 5 14 | # Output :- 15 | # * * * * 1 16 | # * * * 2 1 17 | # * * 3 2 1 18 | # * 4 3 2 1 19 | # 5 4 3 2 1 20 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern155.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,i): 6 | print("*",end=" ") 7 | 8 | for j in range(height-i+1,0,-1): 9 | print(j,end=" ") 10 | 11 | print() 12 | 13 | # Sample Input :- 5 14 | # Output :- 15 | # 5 4 3 2 1 16 | # * 4 3 2 1 17 | # * * 3 2 1 18 | # * * * 2 1 19 | # * * * * 1 20 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern275.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,i+1): 6 | 7 | for k in range(1,j+1): 8 | print(j,end=" ") 9 | 10 | print() 11 | 12 | print() 13 | 14 | # Sample Input :- 3 15 | # Output :- 16 | # 1 17 | # 18 | # 1 19 | # 2 2 20 | # 21 | # 1 22 | # 2 2 23 | # 3 3 3 24 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern139.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(0,height): 4 | 5 | for j in range(0,i): 6 | print(0,end=" ") 7 | 8 | for j in range(1,height-i+1): 9 | print((2*i)+j,end=" ") 10 | 11 | print() 12 | 13 | # Sample Input :- 5 14 | # Output :- 15 | # 1 2 3 4 5 16 | # 0 3 4 5 6 17 | # 0 0 5 6 7 18 | # 0 0 0 7 8 19 | # 0 0 0 0 9 20 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern148.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,i+1): 6 | print(i,end=" ") 7 | 8 | for j in range(height-i,0,-1): 9 | print("*",end=" ") 10 | 11 | print() 12 | 13 | 14 | # Sample Input :- 5 15 | # Output :- 16 | # 1 * * * * 17 | # 1 2 * * * 18 | # 1 2 3 * * 19 | # 1 2 3 4 * 20 | # 1 2 3 4 5 21 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern183.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(height,0,-1): 4 | 5 | for j in range(1,i+1): 6 | 7 | if(i%2 == 0): 8 | print("*",end=" ") 9 | 10 | else: 11 | print(i,end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # 5 5 5 5 5 18 | # * * * * 19 | # 3 3 3 20 | # * * 21 | # 1 22 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern184.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(height,0,-1): 4 | 5 | for j in range(1,i+1): 6 | 7 | if(i%2 == 0): 8 | print("*",end=" ") 9 | 10 | else: 11 | print(j,end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # 1 2 3 4 5 18 | # * * * * 19 | # 1 2 3 20 | # * * 21 | # 1 22 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern185.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(height,0,-1): 4 | 5 | for j in range(1,i+1): 6 | 7 | if(j%2 == 0): 8 | print("*",end=" ") 9 | 10 | else: 11 | print(j,end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # 1 * 3 * 5 18 | # 1 * 3 * 19 | # 1 * 3 20 | # 1 * 21 | # 1 22 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern186.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(height,0,-1): 4 | 5 | for j in range(1,i+1): 6 | 7 | if(j%2 == 0): 8 | print("*",end=" ") 9 | 10 | else: 11 | print(i,end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # 5 * 5 * 5 18 | # 4 * 4 * 19 | # 3 * 3 20 | # 2 * 21 | # 1 22 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern273.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,i+1): 6 | 7 | for k in range(1,j+1): 8 | print(i,end=" ") 9 | 10 | print() 11 | 12 | print() 13 | 14 | # Sample Input :- 3 15 | # Output :- 16 | # 1 17 | # 18 | # 2 19 | # 2 2 20 | # 21 | # 3 22 | # 3 3 23 | # 3 3 3 24 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern34.py: -------------------------------------------------------------------------------- 1 | start = 1 2 | stop = 2 3 | current_num = stop 4 | for row in range(2, 6): 5 | for col in range(start, stop): 6 | current_num -= 1 7 | print(current_num, end=' ') 8 | print("") 9 | start = stop 10 | stop += row 11 | current_num = stop 12 | 13 | ''' 14 | 15 | Output: 16 | 17 | 1 18 | 3 2 19 | 6 5 4 20 | 10 9 8 7 21 | 22 | ''' 23 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern20.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | spaces = n + (n - 1) 4 | counter = 1 5 | f = 1 6 | for i in range(0, n): 7 | for k in range(0, spaces): 8 | print(" ", end="") 9 | for j in range(0, counter): 10 | print(f, end=" ") 11 | f = f + 1 12 | counter = counter + 2 13 | print() 14 | spaces = spaces - 2 15 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern126.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows: ") 2 | n = int(input()) 3 | for i in range(n): 4 | count = i 5 | for j in range(n): 6 | print(count+1, end=" ") 7 | if(count<4): 8 | count+=1 9 | print() 10 | 11 | 12 | # Enter the no of rows: 13 | # 5 14 | # 1 2 3 4 5 15 | # 2 3 4 5 5 16 | # 3 4 5 5 5 17 | # 4 5 5 5 5 18 | # 5 5 5 5 5 19 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern129.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | for i in range(n): 4 | count = 1 5 | for j in range(0,n): 6 | print(count,end=""); 7 | if(j==n-i-1): 8 | count=i+1 9 | print() 10 | 11 | # Enter the number of rows: 12 | # 5 13 | # 1 1 1 1 1 14 | # 1 1 1 1 2 15 | # 1 1 1 3 3 16 | # 1 1 4 4 4 17 | # 1 5 5 5 5 18 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern150.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,height-i+2): 6 | print(height-i+1,end=" ") 7 | 8 | for j in range(1,i): 9 | print("*",end=" ") 10 | 11 | print() 12 | 13 | 14 | # Sample Input :- 5 15 | # Output :- 16 | # 5 5 5 5 5 17 | # 4 4 4 4 * 18 | # 3 3 3 * * 19 | # 2 2 * * * 20 | # 1 * * * * 21 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern154.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,i): 6 | print("*",end=" ") 7 | 8 | for j in range(height-i+1,0,-1): 9 | print(height-i+1,end=" ") 10 | 11 | print() 12 | 13 | # Sample Input :- 5 14 | # Output :- 15 | # 5 5 5 5 5 16 | # * 4 4 4 4 17 | # * * 3 3 3 18 | # * * * 2 2 19 | # * * * * 1 20 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern168.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,i*2): 6 | 7 | if(j <= i): 8 | print(i-j+1,end=" ") 9 | 10 | else: 11 | print(j-i+1,end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 4 16 | # Output :- 17 | # 1 18 | # 2 1 2 19 | # 3 2 1 2 3 20 | # 4 3 2 1 2 3 4 21 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern272.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | no = int(input()) 3 | 4 | for i in range(1,no+1): 5 | 6 | for j in range(1,height+1): 7 | 8 | for k in range(1,j+1): 9 | print(k,end=" ") 10 | 11 | print() 12 | 13 | # Sample Input :- 3 14 | # 2 15 | # Output :- 16 | # 1 17 | # 1 2 18 | # 1 2 3 19 | # 1 20 | # 1 2 21 | # 1 2 3 22 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern274.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,i+1): 6 | 7 | for k in range(1,j+1): 8 | print(j,end=" ") 9 | 10 | print() 11 | 12 | print() 13 | 14 | # Sample Input :- 3 15 | # Output :- 16 | # 1 17 | # 18 | # 1 19 | # 2 2 20 | # 21 | # 1 22 | # 2 2 23 | # 3 3 3 24 | 25 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern110.py: -------------------------------------------------------------------------------- 1 | n=5 2 | for i in range(n): 3 | for j in range (1,n-i): 4 | print('*', end='') 5 | for k in range (i,2*i+1): 6 | print(k+1, end='') 7 | if k+1 == 2*i+1: 8 | for a in range (k, i, -1): 9 | print(a, end='') 10 | break 11 | for l in range (n-i, 1, -1): 12 | print('*', end='') 13 | print() 14 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern16.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,height-i+1): 6 | print("*",end=" ") 7 | 8 | for j in range(1, i+1): 9 | print(i,end=" ") 10 | 11 | print() 12 | 13 | # Sample Input :- 5 14 | # Output :- 15 | # * * * * 1 16 | # * * * 2 2 17 | # * * 3 3 3 18 | # * 4 4 4 4 19 | # 5 5 5 5 5 20 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern164.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | counter = 0 3 | for i in range(0,height) : 4 | for j in range(0,height+1) : 5 | if ( j == counter or j == height - counter and i <= height // 2 ): 6 | print("*",end="") 7 | else : 8 | print(end=" ") 9 | print() 10 | if (i < height // 2) : 11 | counter = counter + 1 -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern190.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | counter = 0 3 | for i in range(0,height) : 4 | for j in range(0,height+1) : 5 | if ( j == counter or j == height - counter and i <= height // 2 ): 6 | print("Y",end="") 7 | else : 8 | print(end=" ") 9 | print() 10 | if (i < height // 2) : 11 | counter = counter + 1 -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern127.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows: ") 2 | n = int(input()) 3 | for i in range(n): 4 | count = i 5 | for j in range(n): 6 | print(n-count, end=" ") 7 | if(n-count<5): 8 | count-=1 9 | print() 10 | 11 | 12 | # Enter the no of rows: 13 | # 5 14 | # 5 5 5 5 5 15 | # 4 5 5 5 5 16 | # 3 4 5 5 5 17 | # 2 3 4 5 5 18 | # 1 2 3 4 5 19 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern232.py: -------------------------------------------------------------------------------- 1 | for i in range(1,6): 2 | for j in range(1,6): 3 | if i==int(5/2)+1 or j==int(5/2)+1: 4 | if abs(i-j)==2: 5 | print(1,end=' ') 6 | elif abs(i-j)==1: 7 | print(2,end=' ') 8 | else: 9 | print(3,end=' ') 10 | else: 11 | print(" ",end=' ') 12 | print(end='\n') 13 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern69.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows:") 2 | n = int(input()) 3 | for i in range(0,n): 4 | for j in range(0,n-i): 5 | if((i+j)%2!=0): 6 | print("1",end=" ") 7 | else: 8 | print("0",end=" ") 9 | print() 10 | 11 | # OUTPUT 12 | # Enter the number of rows: 13 | # 5 14 | # 0 1 0 1 0 15 | # 1 0 1 0 16 | # 0 1 0 17 | # 1 0 18 | # 0 19 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern18.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | spaces = n + (n - 1) 4 | counter = 1 5 | for i in range(n, 0, -1): 6 | n = i 7 | for k in range(0, spaces): 8 | print(" ", end="") 9 | for j in range(0, counter): 10 | print(n, end=" ") 11 | n = n + 1 12 | counter = counter + 2 13 | print() 14 | spaces = spaces - 2 15 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern30.py: -------------------------------------------------------------------------------- 1 | n = int(input("Enter the number of rows: ")) 2 | spaces = n + (n - 1) 3 | counter = 1 4 | a = 64 5 | for i in range(1, n + 1): 6 | b = i 7 | for k in range(0, spaces): 8 | print(" ", end="") 9 | for j in range(0, counter): 10 | print(chr(i+a), end=" ") 11 | counter = counter + 2 12 | spaces = spaces - 2 13 | a = a + 1 14 | print() 15 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern143.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | for i in range(0, height): 3 | print("*", end="") 4 | for j in range(0, height): 5 | if ((i == 0 or i == height - 1) and j < height - 1): 6 | print("*", end="") 7 | elif (j == height - 1 and i != 0 and i != height - 1): 8 | print("*", end="") 9 | else: 10 | print(end=" ") 11 | print() 12 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern155.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | for i in range(0, height): 3 | print("*", end="") 4 | for j in range(0, height): 5 | if ((i == 0 or i == height // 2) and j < height - 1): 6 | print("*", end="") 7 | elif (i < height // 2 and j == height - 1 and i != 0): 8 | print("*", end="") 9 | else: 10 | print(end=" ") 11 | print() 12 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern169.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | for i in range(0, height): 3 | print("D", end="") 4 | for j in range(0, height): 5 | if ((i == 0 or i == height - 1) and j < height - 1): 6 | print("D", end="") 7 | elif (j == height - 1 and i != 0 and i != height - 1): 8 | print("D", end="") 9 | else: 10 | print(end=" ") 11 | print() 12 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern181.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | for i in range(0, height): 3 | print("P", end="") 4 | for j in range(0, height): 5 | if ((i == 0 or i == height // 2) and j < height - 1): 6 | print("P", end="") 7 | elif (i < height // 2 and j == height - 1 and i != 0): 8 | print("P", end="") 9 | else: 10 | print(end=" ") 11 | print() 12 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern316.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(0,height): 4 | 5 | for j in range(1,height): 6 | 7 | if(i == 0 or i == height-j): 8 | print("*",end=" ") 9 | else: 10 | print(end=" ") 11 | 12 | print() 13 | 14 | # Sample Input :- 5 15 | # Output :- 16 | # * * * * 17 | # * 18 | # * 19 | # * 20 | # 8 21 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern326.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(0,height): 4 | 5 | for j in range(1,height): 6 | 7 | if(i == 0 or i == height-j): 8 | print("7",end=" ") 9 | else: 10 | print(end=" ") 11 | 12 | print() 13 | 14 | # Sample Input :- 5 15 | # Output :- 16 | # 7 7 7 7 17 | # 7 18 | # 7 19 | # 7 20 | # 7 21 | -------------------------------------------------------------------------------- /String Patterns/stringpattern9.py: -------------------------------------------------------------------------------- 1 | print('Enter a string') 2 | pattern_string = input() 3 | print('Enter the number of lines') 4 | lines = int(input()) 5 | index = 0 6 | for i in range (lines) : 7 | for j in range (i+1) : 8 | try: 9 | print(pattern_string[index], end=' ') 10 | index+= 1 11 | except: 12 | print(pattern_string[0], end=' ') 13 | index = 1 14 | print(end='\n') 15 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern73.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(0,height): 4 | 5 | for j in range(0,height): 6 | 7 | if(i == j): 8 | print("O",end=" ") 9 | 10 | else : 11 | print("X",end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # O X X X X 18 | # X O X X X 19 | # X X O X X 20 | # X X X O X 21 | # X X X X O 22 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern27.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 3 | rows = int(input()) 4 | i = rows 5 | while i >= 1: 6 | j = rows 7 | while j > i: 8 | # display space 9 | print(' ', end=' ') 10 | j -= 1 11 | k = 1 12 | while k <= i: 13 | print(alpha[i-1], end=' ') 14 | k += 1 15 | print() 16 | i -= 1 17 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern114.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | count = 2*n-1 4 | for i in range(n): 5 | print(" "*i + str(count)*(2*(n-i)-1)) 6 | count-=2 7 | 8 | 9 | # OUTPUT 10 | 11 | # print("Enter the number of rows: ") 12 | # n = int(input()) 13 | # count = 2*n-1 14 | # for i in range(n): 15 | # print(" "*i + str(count)*(2*(n-i)-1)) 16 | # count-=2 17 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern174.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(height,0,-1): 4 | 5 | for j in range(1,i+1): 6 | 7 | if(i%2 == 1): 8 | print(j,end=" ") 9 | 10 | else: 11 | print(i+1-j,end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # 1 2 3 4 5 18 | # 4 3 2 1 19 | # 1 2 3 20 | # 2 1 21 | # 1 22 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern175.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(height,0,-1): 4 | 5 | for j in range(1,i+1): 6 | 7 | if(i%2 == 0): 8 | print(j,end=" ") 9 | 10 | else: 11 | print(6-j,end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # 5 4 3 2 1 18 | # 1 2 3 4 19 | # 5 4 3 20 | # 1 2 21 | # 5 22 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern179.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,i+1): 6 | 7 | if (i % 2 == 0): 8 | print("*",end=" ") 9 | 10 | else: 11 | print(i,end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # 1 18 | # * * 19 | # 3 3 3 20 | # * * * * 21 | # 5 5 5 5 5 22 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern180.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,i+1): 6 | 7 | if (i % 2 == 0): 8 | print("*",end=" ") 9 | 10 | else: 11 | print(j,end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # 1 18 | # * * 19 | # 1 2 3 20 | # * * * * 21 | # 1 2 3 4 5 22 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern181.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,i+1): 6 | 7 | if (j % 2 == 0): 8 | print("*",end=" ") 9 | 10 | else: 11 | print(j,end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # 1 18 | # 1 * 19 | # 1 * 3 20 | # 1 * 3 * 21 | # 1 * 3 * 5 22 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern182.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,i+1): 6 | 7 | if (j % 2 == 0): 8 | print("*",end=" ") 9 | 10 | else: 11 | print(i,end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # 1 18 | # 2 * 19 | # 3 * 3 20 | # 4 * 4 * 21 | # 5 * 5 * 5 22 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern234.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1, height + 1): 4 | 5 | for j in range(1, height + 1): 6 | 7 | if(i == j): 8 | print(1,end=" ") 9 | 10 | else: 11 | print(0,end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # 1 0 0 0 0 18 | # 0 1 0 0 0 19 | # 0 0 1 0 0 20 | # 0 0 0 1 0 21 | # 0 0 0 0 1 22 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern271.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | no = int(input()) 3 | 4 | for i in range(1,no+1): 5 | 6 | for j in range(1,height+1): 7 | 8 | for k in range(1,j+1): 9 | print(j,end=" ") 10 | 11 | print() 12 | 13 | # Sample Input :- 3 14 | # 2 15 | # Output :- 16 | # 1 17 | # 2 2 18 | # 3 3 3 19 | # 1 20 | # 2 2 21 | # 3 3 3 22 | 23 | 24 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern68.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows:") 2 | n = int(input()) 3 | for i in range(0,n): 4 | for j in range(0,n-i): 5 | if(j%2!=0): 6 | print("1",end=" ") 7 | else: 8 | print("0",end=" ") 9 | print() 10 | 11 | 12 | # OUTPUT 13 | # Enter the number of rows: 14 | # 5 15 | # 0 1 0 1 0 16 | # 0 1 0 1 17 | # 0 1 0 18 | # 0 1 19 | # 0 20 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolicpattern180.py: -------------------------------------------------------------------------------- 1 | n = int(input("Width: ")) 2 | 3 | def gen180(n:int): 4 | A = ['*'*n] 5 | A.extend([f'*{" "*(n-2)}*' for i in range(1,n//2)]) 6 | A.append(A[0]) 7 | A.extend([f'{" "*(n-1)}*' for i in range(1,n//2)]) 8 | A.append(A[0]) 9 | return "\n".join(A) 10 | 11 | print(gen180(n)) 12 | 13 | """ 14 | Width: 5 15 | ***** 16 | * * 17 | ***** 18 | * 19 | ***** 20 | """ -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern14.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(height, 0, -1): 4 | 5 | for j in range(1,i+1): 6 | 7 | print(i,end=" ") 8 | 9 | for j in range(1, height-i+1): 10 | print("*",end=" ") 11 | 12 | print() 13 | 14 | # Sample Input :- 5 15 | # Output :- 16 | # 5 5 5 5 5 17 | # 4 4 4 4 * 18 | # 3 3 3 * * 19 | # 2 2 * * * 20 | # 1 * * * * 21 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern15.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(height, 0, -1): 4 | 5 | for j in range(1,i+1): 6 | 7 | print(j,end=" ") 8 | 9 | for j in range(1, height-i+1): 10 | print("*",end=" ") 11 | 12 | print() 13 | 14 | # Sample Input :- 5 15 | # Output :- 16 | # 1 2 3 4 5 17 | # 1 2 3 4 * 18 | # 1 2 3 * * 19 | # 1 2 * * * 20 | # 1 * * * * 21 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern124.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows: ") 2 | n = int(input()) 3 | for i in range(n): 4 | for j in range(n): 5 | if(i%2==0): 6 | print(j+1, end=" ") 7 | else: 8 | print(n-j, end=" ") 9 | print() 10 | 11 | # OUTPUT 12 | 13 | # Enter the no of rows: 14 | # 5 15 | # 1 2 3 4 5 16 | # 5 4 3 2 1 17 | # 1 2 3 4 5 18 | # 5 4 3 2 1 19 | # 1 2 3 4 5 20 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern144.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,height+1): 6 | 7 | if(i == j): 8 | print(i,end=" ") 9 | 10 | else: 11 | print(0,end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # 1 0 0 0 0 18 | # 0 2 0 0 0 19 | # 0 0 3 0 0 20 | # 0 0 0 4 0 21 | # 0 0 0 0 5 22 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern21.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(0,height) : 4 | 5 | for j in range(0, height): 6 | 7 | if(i%2 != 0): 8 | print(1,end = " ") 9 | else: 10 | print(0, end=" ") 11 | 12 | print() 13 | 14 | # Sample Input :- 5 15 | # Output :- 16 | # 0 0 0 0 0 17 | # 1 1 1 1 1 18 | # 0 0 0 0 0 19 | # 1 1 1 1 1 20 | # 0 0 0 0 0 21 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern22.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(0,height) : 4 | 5 | for j in range(0, height): 6 | 7 | if(i%2 == 0): 8 | print(1,end = " ") 9 | else: 10 | print(0, end=" ") 11 | 12 | print() 13 | 14 | # Sample Input :- 5 15 | # Output :- 16 | # 1 1 1 1 1 17 | # 0 0 0 0 0 18 | # 1 1 1 1 1 19 | # 0 0 0 0 0 20 | # 1 1 1 1 1 21 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern224.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1, height + 1): 4 | 5 | for j in range(1, i + 1): 6 | 7 | if(i == j): 8 | print(i - 1,end=" ") 9 | 10 | else: 11 | print("*",end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # 0 18 | # * 1 19 | # * * 2 20 | # * * * 3 21 | # * * * * 4 22 | # * * * * * 5 23 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern23.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(0,height) : 4 | 5 | for j in range(0, height): 6 | 7 | if(j%2 != 0): 8 | print(1,end = " ") 9 | else: 10 | print(0, end=" ") 11 | 12 | print() 13 | 14 | # Sample Input :- 5 15 | # Output :- 16 | # 0 1 0 1 0 17 | # 0 1 0 1 0 18 | # 0 1 0 1 0 19 | # 0 1 0 1 0 20 | # 0 1 0 1 0 21 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern70.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows:") 2 | n = int(input()) 3 | for i in range(0,n): 4 | for j in range(0,n-i): 5 | if((i+j)%2==0): 6 | print("1",end=" ") 7 | else: 8 | print("0",end=" ") 9 | print() 10 | 11 | 12 | # OUTPUT 13 | # Enter the number of rows: 14 | # 5 15 | # 1 0 1 0 1 16 | # 0 1 0 1 17 | # 1 0 1 18 | # 0 1 19 | # 1 20 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern3.py: -------------------------------------------------------------------------------- 1 | """ 2 | In this question, we have to print stars from n to 0 3 | We can use a reversed for loop starting from n which goes till 0 and has -1 as the step 4 | Since the upper limit is ignored, the loop will end on 1 star 5 | """ 6 | n = 5 # size 7 | for i in range(n, 0, -1): 8 | print("*"*i) 9 | 10 | """ 11 | OUTPUT: 12 | 13 | ***** 14 | **** 15 | *** 16 | ** 17 | * 18 | """ -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern69.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(0,height+1): 4 | 5 | for j in range(0,i+1): 6 | 7 | if(j == i): 8 | print(i,end=" ") 9 | 10 | else: 11 | print("*",end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # 0 18 | # * 1 19 | # * * 2 20 | # * * * 3 21 | # * * * * 4 22 | # * * * * * 5 23 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern70.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(height,-1,-1): 4 | 5 | for j in range(0,i+1): 6 | 7 | if(j == i): 8 | print(i,end=" ") 9 | 10 | else: 11 | print("*",end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # * * * * * 5 18 | # * * * * 4 19 | # * * * 3 20 | # * * 2 21 | # * 1 22 | # 0 23 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern147.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,i+1): 6 | print(height-i+1,end=" ") 7 | 8 | for j in range(i,height): 9 | c = chr(i+64) 10 | print(c,end=" ") 11 | 12 | print() 13 | 14 | # Sample Input :- 5 15 | # Output :- 16 | # 5 A A A A 17 | # 4 4 B B B 18 | # 3 3 3 C C 19 | # 2 2 2 2 D 20 | # 1 1 1 1 1 21 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern167.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | x = 0 3 | 4 | for i in range(1,height+1): 5 | 6 | for j in range(1,i*2): 7 | 8 | if(j <= i): 9 | print(j+x,end=" ") 10 | 11 | else: 12 | print(i*2-j+x,end=" ") 13 | 14 | x += i 15 | print() 16 | 17 | # Sample Input :- 4 18 | # Output :- 19 | # 1 20 | # 2 3 2 21 | # 4 5 6 5 4 22 | # 7 8 9 10 9 8 7 23 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern17.py: -------------------------------------------------------------------------------- 1 | # Numeric Pattern 17 2 | 3 | """ 4 | Desired Pattern: 5 | 6 | 0 1 0 1 0 7 | 1 0 1 0 1 8 | 0 1 0 1 0 9 | 1 0 1 0 1 10 | 0 1 0 1 0 11 | 12 | """ 13 | 14 | # Creating a list of all nums 15 | nums = ['0'] 16 | 17 | for i in range(12): 18 | nums += ['1', '0'] 19 | 20 | # Printing 5 nums per loop 21 | i = 0 22 | for _ in range(5): 23 | print(" ".join(nums[i : i + 5])) 24 | i += 5 25 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern203.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(height,0,-1): 4 | 5 | for j in range(1,i+1): 6 | 7 | if(i%2 == 0): 8 | c = chr(i+64) 9 | print(c,end=" ") 10 | 11 | else: 12 | print(i,end=" ") 13 | 14 | print() 15 | 16 | # Sample Input :- 5 17 | # Output :- 18 | # 5 5 5 5 5 19 | # D D D D 20 | # 3 3 3 21 | # B B 22 | # 1 23 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern204.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(height,0,-1): 4 | 5 | for j in range(1,i+1): 6 | 7 | if(i%2 == 0): 8 | c = chr(j+64) 9 | print(c,end=" ") 10 | 11 | else: 12 | print(j,end=" ") 13 | 14 | print() 15 | 16 | # Sample Input :- 5 17 | # Output :- 18 | # 1 2 3 4 5 19 | # A B C D 20 | # 1 2 3 21 | # A B 22 | # 1 23 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern24.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(0,height) : 4 | 5 | for j in range(0, height): 6 | 7 | if(j%2 == 0): 8 | print(1,end = " ") 9 | else: 10 | print(0, end=" ") 11 | 12 | print() 13 | 14 | # Sample Input :- 5 15 | # Output :- 16 | # 1 0 1 0 1 17 | # 1 0 1 0 1 18 | # 1 0 1 0 1 19 | # 1 0 1 0 1 20 | # 1 0 1 0 1 21 | 22 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern161.py: -------------------------------------------------------------------------------- 1 | n = 6 2 | counter = 3 3 | iterations = 0 4 | for i in range(0, n): 5 | for j in range(0, counter): 6 | if counter == 2 and j == 0: 7 | print(end=" ") 8 | elif counter == 1: 9 | print(end=" ") 10 | print("*", end=" ") 11 | iterations = iterations + 1 12 | if iterations % 2 == 0: 13 | counter = counter - 1 14 | print() 15 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern18.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(height, 0, -1): 4 | 5 | for j in range(1, height-i+1): 6 | 7 | print("*",end=" ") 8 | 9 | for j in range(1,i+1): 10 | print(i,end=" ") 11 | 12 | print() 13 | 14 | # Sample Input :- 5 15 | # Output :- 16 | # 5 5 5 5 5 17 | # * 4 4 4 4 18 | # * * 3 3 3 19 | # * * * 2 2 20 | # * * * * 1 21 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern19.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(height, 0, -1): 4 | 5 | for j in range(1, height-i+1): 6 | 7 | print("*",end=" ") 8 | 9 | for j in range(i,0,-1): 10 | print(j,end=" ") 11 | 12 | print() 13 | 14 | # Sample Input :- 5 15 | # Output :- 16 | # 5 4 3 2 1 17 | # * 4 3 2 1 18 | # * * 3 2 1 19 | # * * * 2 1 20 | # * * * * 1 21 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern71.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,height+1): 6 | 7 | if(i == j or i == height-j+1): 8 | print("*",end=" ") 9 | 10 | else : 11 | print(end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # * * 18 | # * * 19 | # * 20 | # * * 21 | # * * 22 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern72.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,height+1): 6 | 7 | if(i == height//2+1 or j == height//2+1): 8 | print("*",end=" ") 9 | 10 | else : 11 | print(end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # * 18 | # * 19 | # * * * * * 20 | # * 21 | # * 22 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern149.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | for i in range(0, height): 3 | for j in range(0, height): 4 | if (i == height - 1 and (j > 0 and j < height - 1)): 5 | print("*", end="") 6 | elif ((j == height - 1 and i != height - 1) or (i > (height // 2) - 1 and j == 0 and i != height - 1)): 7 | print("*", end="") 8 | else: 9 | print(end=" ") 10 | print() 11 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern141.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,height+1): 6 | 7 | if(j < height//2+1): 8 | print(0,end=" ") 9 | 10 | else: 11 | print(1,end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # 0 0 1 1 1 18 | # 0 0 1 1 1 19 | # 0 0 1 1 1 20 | # 0 0 1 1 1 21 | # 0 0 1 1 1 22 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern142.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,height+1): 6 | 7 | if(i < height//2+1): 8 | print(0,end=" ") 9 | 10 | else: 11 | print(1,end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # 0 0 0 0 0 18 | # 0 0 0 0 0 19 | # 1 1 1 1 1 20 | # 1 1 1 1 1 21 | # 1 1 1 1 1 22 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern160.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,height+1): 6 | 7 | if(i == height - j + 1) : 8 | print("*",end=" ") 9 | 10 | else : 11 | print(j,end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # 1 2 3 4 * 18 | # 1 2 3 * 5 19 | # 1 2 * 4 5 20 | # 1 * 3 4 5 21 | # * 2 3 4 5 22 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern19.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(0,height) : 4 | 5 | for j in range(0, height): 6 | 7 | if(i%2 == 0 and j%2 == 0): 8 | print(1,end = " ") 9 | else: 10 | print(0, end=" ") 11 | 12 | print() 13 | 14 | # Sample Input :- 5 15 | # Output :- 16 | # 1 0 1 0 1 17 | # 0 0 0 0 0 18 | # 1 0 1 0 1 19 | # 0 0 0 0 0 20 | # 1 0 1 0 1 21 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern199.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,i+1): 6 | 7 | if(i%2 == 0): 8 | c = chr(i+64) 9 | print(c,end=" ") 10 | 11 | else: 12 | print(i,end=" ") 13 | 14 | print() 15 | 16 | # Sample Input :- 5 17 | # Output :- 18 | # 1 19 | # B B 20 | # 3 3 3 21 | # D D D D 22 | # 5 5 5 5 5 23 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern20.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(0,height) : 4 | 5 | for j in range(0, height): 6 | 7 | if(i%2 == 0 and j%2 != 0): 8 | print(1,end = " ") 9 | else: 10 | print(0, end=" ") 11 | 12 | print() 13 | 14 | # Sample Input :- 15 | # Output :- 5 16 | # 0 1 0 1 0 17 | # 0 0 0 0 0 18 | # 0 1 0 1 0 19 | # 0 0 0 0 0 20 | # 0 1 0 1 0 21 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern200.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,i+1): 6 | 7 | if(i%2 == 0): 8 | c = chr(j+64) 9 | print(c,end=" ") 10 | 11 | else: 12 | print(j,end=" ") 13 | 14 | print() 15 | 16 | # Sample Input :- 5 17 | # Output :- 18 | # 1 19 | # A B 20 | # 1 2 3 21 | # A B C D 22 | # 1 2 3 4 5 23 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern241.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1, height + 1): 4 | 5 | for j in range(1,i+1): 6 | 7 | if(i == height or j == 1 or i == j): 8 | print(i,end=" ") 9 | 10 | else: 11 | print(end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # 1 18 | # 2 2 19 | # 3 3 20 | # 4 4 21 | # 5 5 5 5 5 22 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern242.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1, height + 1): 4 | 5 | for j in range(1,i+1): 6 | 7 | if(i == height or j == 1 or i == j): 8 | print(j,end=" ") 9 | 10 | else: 11 | print(end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # 1 18 | # 1 2 19 | # 1 3 20 | # 1 4 21 | # 1 2 3 4 5 22 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern85.py: -------------------------------------------------------------------------------- 1 | def pypart2(n): 2 | k = 2*n - 2 3 | counter = 1 4 | flag=n 5 | for i in range(0, n): 6 | for j in range(0, k): 7 | print(end=" ") 8 | k = k - 2 9 | for j in range(0, i+1): 10 | print(counter-j, end=" ") 11 | counter=counter+flag 12 | flag = flag+1 13 | print("\r") 14 | 15 | print("Enter the number of rows: ") 16 | n = int(input()) 17 | pypart2(n) 18 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern32.py: -------------------------------------------------------------------------------- 1 | n = int(input("Enter the number of rows: ")) 2 | spaces = n + (n - 1) 3 | counter = 1 4 | a = 64 5 | for i in range(1, n + 1): 6 | b = i 7 | for k in range(0, spaces): 8 | print(" ", end="") 9 | for j in range(0, counter): 10 | print(chr(b+a), end=" ") 11 | b = b - 1 12 | counter = counter + 2 13 | spaces = spaces - 2 14 | a = a + 1 15 | print() 16 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern63.py: -------------------------------------------------------------------------------- 1 | n = int(input("Enter the number of rows: ")) 2 | spaces = n 3 | counter = 1 4 | for i in range(1, n+1): 5 | for k in range(0, spaces): 6 | print(" ", end="") 7 | for j in range(1, counter+1): 8 | if i % 2 == 0: 9 | print("*", end=" ") 10 | else: 11 | print(i, end=" ") 12 | counter = counter + 1 13 | spaces = spaces - 1 14 | print() 15 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern74.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,height+1): 6 | 7 | if(i > j): 8 | print("X",end=" ") 9 | 10 | else: 11 | print("O",end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # O O O O O 18 | # X O O O O 19 | # X X O O O 20 | # X X X O O 21 | # X X X X O 22 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern95.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | number = int(input()) 3 | 4 | for i in range(1,number+1): 5 | 6 | for j in range(1,height+1): 7 | 8 | for k in range(1,j+1): 9 | 10 | print("*",end=" ") 11 | 12 | print() 13 | 14 | # Sample Input :- 3 15 | # 2 16 | # Output :- 17 | # * 18 | # * * 19 | # * * * 20 | # * 21 | # * * 22 | # * * * 23 | 24 | 25 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern201.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(height,0,-1): 4 | 5 | for j in range(1,i+1): 6 | 7 | if(i%2 == 0): 8 | print(i,end=" ") 9 | 10 | else: 11 | c = chr(i+64) 12 | print(c,end=" ") 13 | 14 | print() 15 | 16 | # Sample Input :- 5 17 | # Output :- 18 | # E E E E E 19 | # 4 4 4 4 20 | # C C C 21 | # 2 2 22 | # A 23 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern202.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(height,0,-1): 4 | 5 | for j in range(1,i+1): 6 | 7 | if(i%2 == 0): 8 | print(j,end=" ") 9 | 10 | else: 11 | c = chr(j+64) 12 | print(c,end=" ") 13 | 14 | print() 15 | 16 | # Sample Input :- 5 17 | # Output :- 18 | # A B C D E 19 | # 1 2 3 4 20 | # A B C 21 | # 1 2 22 | # A 23 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern86.py: -------------------------------------------------------------------------------- 1 | def pypart2(n): 2 | k = 2*n - 2 3 | counter = n 4 | flag=n-1 5 | for i in range(0, n): 6 | for j in range(0, k): 7 | print(end=" ") 8 | k = k - 2 9 | for j in range(0, i+1): 10 | print(counter-j, end=" ") 11 | counter=counter+flag 12 | flag = flag-1 13 | print("\r") 14 | 15 | print("Enter the number of rows: ") 16 | n = int(input()) 17 | pypart2(n) 18 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern19.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | f = n 4 | spaces = n + (n - 1) 5 | counter = 1 6 | for i in range(n, 0, -1): 7 | a = f 8 | for k in range(0, spaces): 9 | print(" ", end="") 10 | for j in range(0, counter): 11 | print(a, end=" ") 12 | a = a - 1 13 | counter = counter + 2 14 | print() 15 | f = f + 1 16 | spaces = spaces - 2 17 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern153.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(height,i,-1): 6 | 7 | print(end=" ") 8 | 9 | for k in range(1,height): 10 | 11 | print("*",end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # * * * * 18 | # * * * * 19 | # * * * * 20 | # * * * * 21 | # * * * * 22 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern196.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | for i in range(0,height) : 3 | print("*",end="") 4 | for j in range(0,height) : 5 | if ( (i == 0 or i == height // 2) and j < height - 1 ): 6 | print("*",end="") 7 | elif ( i < height // 2 and j == height - 1 and i != 0 ) : 8 | print("*",end="") 9 | else : 10 | print(end=" ") 11 | print() -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern120.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1,2): 4 | 5 | for j in range(1,i+1): 6 | print(i,end=" ") 7 | 8 | print() 9 | 10 | for i in range(height-2,0,-2): 11 | 12 | for j in range(height,height-i,-1): 13 | print(i,end=" ") 14 | 15 | print() 16 | 17 | # Sample Input :- 5 18 | # Output :- 19 | # 1 20 | # 3 3 3 21 | # 5 5 5 5 5 22 | # 3 3 3 23 | # 1 24 | 25 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern133.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows: ") 2 | n = int(input()) 3 | count = 0 4 | for i in range(n): 5 | for j in range(n): 6 | print(count+1, end=" ") 7 | if(count==7): 8 | count=-1 9 | count+=1 10 | 11 | print() 12 | 13 | 14 | 15 | # Enter the no of rows: 16 | # 5 17 | # 1 2 3 4 5 18 | # 6 7 8 1 2 19 | # 3 4 5 6 7 20 | # 8 1 2 3 4 21 | # 5 6 7 8 1 22 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern226.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1, height + 1): 4 | 5 | for j in range(1, height + 1): 6 | 7 | if(i == j or i == height - j + 1): 8 | print(i,end=" ") 9 | 10 | else: 11 | print(end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # 1 1 18 | # 2 2 19 | # 3 20 | # 4 4 21 | # 5 5 22 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern228.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1, height + 1): 4 | 5 | for j in range(1, height + 1): 6 | 7 | if(i == j or i == height - j + 1): 8 | print(j,end=" ") 9 | 10 | else: 11 | print(end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # 1 5 18 | # 2 4 19 | # 3 20 | # 2 4 21 | # 1 5 22 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern37.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1) : 4 | 5 | for j in range(1, i+1): 6 | 7 | m = i*j 8 | if(m <= 9): 9 | print("",m,end = " ") 10 | else: 11 | print(m,end = " ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # 1 18 | # 2 4 19 | # 3 6 9 20 | # 4 8 12 16 21 | # 5 10 15 20 25 22 | 23 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern17.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(height,0,-1): 6 | 7 | if(j <= i): 8 | print(j,end=" ") 9 | 10 | else: 11 | print("*",end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # * * * * 1 18 | # * * * 2 1 19 | # * * 3 2 1 20 | # * 4 3 2 1 21 | # 5 4 3 2 1 22 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern199.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | for i in range(0, height): 3 | for j in range(0, height): 4 | if i == 0 or i == height // 2 or i == height - 1: 5 | print("*", end="") 6 | elif i < height // 2 and j == 0: 7 | print("*", end="") 8 | elif i > height // 2 and j == height - 1: 9 | print("*", end="") 10 | else: 11 | print(end=" ") 12 | print() 13 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern7.py: -------------------------------------------------------------------------------- 1 | n = 5 2 | for rows in range(n, 0, -1): 3 | for columns in range(0, n-rows): 4 | print(end=" ") # printing space and staying in same line 5 | for columns in range(0, rows): 6 | print("*", end=" ") # printing * and staying in same line 7 | print() # printing new line 8 | 9 | """ 10 | OUTPUT: 11 | 12 | * * * * * 13 | * * * * 14 | * * * 15 | * * 16 | * 17 | """ -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern164.py: -------------------------------------------------------------------------------- 1 | 2 | height = int(input()) 3 | 4 | for i in range(1,height+1): 5 | 6 | if(i%2 == 0): 7 | 8 | for j in range(i,0,-1): 9 | print(j,end=" ") 10 | 11 | else: 12 | for j in range(1,i+1): 13 | print(j,end=" ") 14 | 15 | print() 16 | 17 | # Sample Input :- 5 18 | # Output :- 19 | # 1 20 | # 2 1 21 | # 1 2 3 22 | # 4 3 2 1 23 | # 1 2 3 4 5 24 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern197.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,i+1): 6 | 7 | if(i%2 == 0): 8 | print(i,end=" ") 9 | 10 | else: 11 | c = chr(i+64) 12 | print(c,end=" ") 13 | 14 | print() 15 | 16 | # Sample Input :- 5 17 | # Output :- 18 | # A 19 | # 2 2 20 | # C C C 21 | # 4 4 4 4 22 | # E E E E E 23 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern198.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,i+1): 6 | 7 | if(i%2 == 0): 8 | print(j,end=" ") 9 | 10 | else: 11 | c = chr(j+64) 12 | print(c,end=" ") 13 | 14 | print() 15 | 16 | # Sample Input :- 5 17 | # Output :- 18 | # A 19 | # 1 2 20 | # A B C 21 | # 1 2 3 4 22 | # A B C D E 23 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern292.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | x = height//2+1 3 | 4 | for i in range(1,height+1): 5 | 6 | for j in range(1,x+1): 7 | print(i,end=" ") 8 | 9 | if(i <= height//2): 10 | x -= 1 11 | 12 | else: 13 | x += 1 14 | 15 | print() 16 | 17 | # Sample Input :- 7 18 | # Output :- 19 | # 1 1 1 1 20 | # 2 2 2 21 | # 3 3 22 | # 4 23 | # 5 5 24 | # 6 6 6 25 | # 7 7 7 7 26 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern293.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | x = height//2+1 3 | 4 | for i in range(1,height+1): 5 | 6 | for j in range(1,x+1): 7 | print(j,end=" ") 8 | 9 | if(i <= height//2): 10 | x -= 1 11 | 12 | else: 13 | x += 1 14 | 15 | print() 16 | 17 | # Sample Input :- 7 18 | # Output :- 19 | # 1 2 3 4 20 | # 1 2 3 21 | # 1 2 22 | # 1 23 | # 1 2 24 | # 1 2 3 25 | # 1 2 3 4 26 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern309.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(0,height): 4 | 5 | for j in range(0,height): 6 | 7 | if(i == 0 or j == 0 or i == height-1 or j == height-1 or i == height-j-1): 8 | print("*",end=" ") 9 | else: 10 | print(end=" ") 11 | print() 12 | 13 | # Sample Input :- 5 14 | # * * * * * 15 | # * * * 16 | # * * * 17 | # * * * 18 | # * * * * * 19 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern31.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | m = 1 3 | 4 | for i in range(1,height+1) : 5 | 6 | for j in range(1, i+1): 7 | 8 | if(m <= 9): 9 | print("",m,end = " ") 10 | else: 11 | print(m,end = " ") 12 | m+=1 13 | 14 | print() 15 | 16 | # Sample Input :- 5 17 | # Output :- 18 | # 1 19 | # 2 3 20 | # 4 5 6 21 | # 7 8 9 10 22 | # 11 12 13 14 15 23 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern327.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(0,height): 4 | 5 | for j in range(0,height): 6 | 7 | if(i == 0 or i == height//2 or i == height-1 or j == 0 or j == height-1): 8 | print("8",end=" ") 9 | else: 10 | print(end=" ") 11 | print() 12 | 13 | # Sample Input :- 5 14 | # 8 8 8 8 8 15 | # 8 8 16 | # 8 8 8 8 8 17 | # 8 8 18 | # 8 8 8 8 8 19 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern84.py: -------------------------------------------------------------------------------- 1 | def pypart2(n): 2 | k = 2*n - 2 3 | counter = 1 4 | flag=n 5 | for i in range(0, n): 6 | for j in range(0, k): 7 | print(end=" ") 8 | k = k - 2 9 | for j in range(0, i+1): 10 | print(counter-j, end=" ") 11 | counter=counter+flag 12 | flag = flag+1 13 | print("\r") 14 | 15 | print("Enter the number of rows: ") 16 | n = int(input()) 17 | pypart2(n) 18 | 19 | 20 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern21.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | spaces = n + (n - 1) 4 | counter = 1 5 | f = 0 6 | b = 0 7 | for i in range(0, n): 8 | f = b 9 | for k in range(0, spaces): 10 | print(" ", end="") 11 | for j in range(0, counter): 12 | print(abs(f), end=" ") 13 | f = f - 1 14 | counter = counter + 2 15 | print() 16 | b = b + 1 17 | spaces = spaces - 2 18 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern38.py: -------------------------------------------------------------------------------- 1 | n, h = map(int, input("Enter the number of rows and starting number respectively: ").split(" ")) 2 | spaces = 1 3 | counter = n + 4 4 | a = 64 5 | for i in range(n, 0, -1): 6 | b = i 7 | for k in range(0, spaces): 8 | print(" ", end=" ") 9 | for j in range(0, counter): 10 | print(h, end=" ") 11 | counter = counter - 2 12 | spaces = spaces + 1 13 | h = h - 2 14 | print() 15 | -------------------------------------------------------------------------------- /Pyramid Patterns/pyramidpattern80.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | k = height-1 3 | 4 | for i in range(1,height+1): 5 | 6 | for j in range(1,k+1): 7 | print(end=" ") 8 | 9 | for j in range(1,i*2+1): 10 | print("*",end=" ") 11 | 12 | k -= 1 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # * * 18 | # * * * * 19 | # * * * * * * 20 | # * * * * * * * * 21 | # * * * * * * * * * * 22 | -------------------------------------------------------------------------------- /String Patterns/stringpattern7.py: -------------------------------------------------------------------------------- 1 | import math 2 | print('Enter a string') 3 | pattern_string = input() 4 | print('Enter the number of letters to be printed in each line') 5 | num = int(input()) 6 | index = 0 7 | for i in range (math.ceil(len(pattern_string)/num)) : 8 | for j in range (num): 9 | try: 10 | print(pattern_string[index], end=' ') 11 | index+= 1 12 | except: 13 | print(' ', end ='') 14 | print(end ='\n') 15 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolicpattern49.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | spaces = n 4 | counter = 1 5 | for i in range(0, n): 6 | for k in range(0, spaces): 7 | print(" ", end=" ") 8 | for j in range(0, counter): 9 | if i % 2 != 0: 10 | print("*", end=" ") 11 | else: 12 | print("#", end=" ") 13 | counter = counter + 1 14 | print() 15 | spaces = spaces - 1 16 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern12.py: -------------------------------------------------------------------------------- 1 | [13:04, 23/01/2022] Mahak Garg: height = int(input()) 2 | 3 | for i in range(1, height+1): 4 | 5 | for j in range(1,i+1): 6 | 7 | print(i,end=" ") 8 | 9 | for j in range(1, height-i+1): 10 | print("*",end=" ") 11 | 12 | print() 13 | 14 | # Sample Input :- 5 15 | # Output :- 16 | # 1 * * * * 17 | # 2 2 * * * 18 | # 3 3 3 * * 19 | # 4 4 4 4 * 20 | # 5 5 5 5 5 21 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern13.py: -------------------------------------------------------------------------------- 1 | [13:04, 23/01/2022] Mahak Garg: height = int(input()) 2 | 3 | for i in range(1, height+1): 4 | 5 | for j in range(1,i+1): 6 | 7 | print(j,end=" ") 8 | 9 | for j in range(1, height-i+1): 10 | print("*",end=" ") 11 | 12 | print() 13 | 14 | # Sample Input :- 5 15 | # Output :- 16 | # 1 * * * * 17 | # 1 2 * * * 18 | # 1 2 3 * * 19 | # 1 2 3 4 * 20 | # 1 2 3 4 5 21 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern198.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | width = 2 * height - 1 3 | half = height // 2 4 | for i in range(0, height): 5 | print("*", end="") 6 | for j in range(0, width): 7 | if (i == 0 or i == half) and j < (width - 2): 8 | print("*", end="") 9 | elif j == (width - 2) and not (i == 0 or i == half): 10 | print("*", end="") 11 | else: 12 | print(end=" ") 13 | print() 14 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern6.py: -------------------------------------------------------------------------------- 1 | n = 5 # size 2 | for rows in range(n): 3 | for columns in range(-n, -rows-1): 4 | print(" ", end="") # printing space and staying in same line 5 | for columns in range(rows+1): 6 | print("* ", end="") # printing * and staying in same line 7 | print() # printing new line 8 | 9 | """ 10 | OUTPUT: 11 | 12 | * 13 | * * 14 | * * * 15 | * * * * 16 | * * * * * 17 | """ -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern62.py: -------------------------------------------------------------------------------- 1 | 2 | alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 3 | print("Enter the no of rows: ") 4 | n = int(input()) 5 | for i in range(0, n): 6 | for k in range(0,n-i-1): 7 | print("*",end=" ") 8 | for j in range(0, i+1): 9 | print(alpha[i], end=" ") 10 | print() 11 | 12 | # Enter the no of rows: 13 | # 5 14 | # * * * * A 15 | # * * * B B 16 | # * * C C C 17 | # * D D D D 18 | # E E E E E 19 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern163.py: -------------------------------------------------------------------------------- 1 | 2 | height = int(input()) 3 | 4 | for i in range(1,height+1): 5 | c = 1 6 | 7 | for j in range(1,i+1): 8 | 9 | if(i%2 == 0): 10 | print(j*2,end=" ") 11 | 12 | else: 13 | print(c,end=" ") 14 | c += 2 15 | 16 | print() 17 | 18 | # Sample Input :- 5 19 | # Output :- 20 | # 1 21 | # 2 4 22 | # 1 3 5 23 | # 2 4 6 8 24 | # 1 3 5 7 9 25 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern227.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1, height + 1): 4 | 5 | for j in range(1, height + 1): 6 | 7 | if(i == j or i == height - j + 1): 8 | print(height - i + 1,end=" ") 9 | 10 | else: 11 | print(end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # 5 5 18 | # 4 4 19 | # 3 20 | # 2 2 21 | # 1 1 22 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern312.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(0,height): 4 | 5 | for j in range(0,height): 6 | 7 | if(i == 0 or i == height//2 or i == height-1 or j == height-1): 8 | print("*",end=" ") 9 | else: 10 | print(end=" ") 11 | print() 12 | 13 | # Sample Input :- 5 14 | # Output :- 15 | # * * * * * 16 | # * 17 | # * * * * * 18 | # * 19 | # * * * * * 20 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern322.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(0,height): 4 | 5 | for j in range(0,height): 6 | 7 | if(i == 0 or i == height//2 or i == height-1 or j == height-1): 8 | print("3",end=" ") 9 | else: 10 | print(end=" ") 11 | print() 12 | 13 | # Sample Input :- 5 14 | # Output :- 15 | # * * * * * 16 | # * 17 | # * * * * * 18 | # * 19 | # * * * * * 20 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern116.py: -------------------------------------------------------------------------------- 1 | n = 7 2 | a = n//2+1 3 | for i in range (a): 4 | for j in range (i+1): 5 | if j==i or j==0: 6 | print(' *', end=' ') 7 | else: 8 | print(' ', end=' ') 9 | print() 10 | for i in range (n-a, 0, -1): 11 | for j in range (i): 12 | if j == 0 or j == i-1: 13 | print(' *', end=' ') 14 | else: 15 | print(' ', end=' ') 16 | print() 17 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern157.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows:") 2 | n = int(input()) 3 | counter = n 4 | iterations = 0 5 | spaces = 0 6 | for i in range(0, n): 7 | for k in range(0, spaces): 8 | print(" ", end=" ") 9 | for j in range(0, counter): 10 | print("*", end=" ") 11 | iterations = iterations + 1 12 | if iterations % 2 == 0: 13 | counter = counter - 2 14 | spaces = spaces + 2 15 | print() 16 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern82.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(0,height): 4 | 5 | for j in range(0,height): 6 | 7 | if(i == height-1 or j == 0 or i == j): 8 | print("*",end=" ") 9 | 10 | else: 11 | print(end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # * 18 | # * * 19 | # * * 20 | # * * 21 | # * * * * * 22 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern96.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | number = int(input()) 3 | 4 | for i in range(1,number+1): 5 | 6 | for j in range(1,i+1): 7 | 8 | for k in range(1,j+1): 9 | 10 | print("*",end=" ") 11 | 12 | print() 13 | 14 | print() 15 | 16 | # Sample Input :- 6 17 | # 3 18 | # Output :- 19 | # * 20 | # 21 | # * 22 | # * * 23 | # 24 | # * 25 | # * * 26 | # * * * 27 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern157.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | width = 2*height - 1 3 | half = (height // 2) 4 | for i in range(0, height): 5 | print("*", end="") 6 | for j in range(0, width): 7 | if ((i == 0 or i == half) and j < (width - 2)): 8 | print("*", end="") 9 | elif (j == (width - 2) and not(i == 0 or i == half)): 10 | print("*", end="") 11 | else: 12 | print(end=" ") 13 | print() 14 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern158.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | for i in range(0, height): 3 | for j in range(0, height): 4 | if ((i == 0 or i == height // 2 or i == height - 1)): 5 | print("*", end="") 6 | elif (i < height // 2 and j == 0): 7 | print("*", end="") 8 | elif (i > height // 2 and j == height - 1): 9 | print("*", end="") 10 | else: 11 | print(end=" ") 12 | print() 13 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern183.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | width = 2*height - 1 3 | half = (height // 2) 4 | for i in range(0, height): 5 | print("R", end="") 6 | for j in range(0, width): 7 | if ((i == 0 or i == half) and j < (width - 2)): 8 | print("R", end="") 9 | elif (j == (width - 2) and not(i == 0 or i == half)): 10 | print("R", end="") 11 | else: 12 | print(end=" ") 13 | print() 14 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern184.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | for i in range(0, height): 3 | for j in range(0, height): 4 | if ((i == 0 or i == height // 2 or i == height - 1)): 5 | print("S", end="") 6 | elif (i < height // 2 and j == 0): 7 | print("S", end="") 8 | elif (i > height // 2 and j == height - 1): 9 | print("S", end="") 10 | else: 11 | print(end=" ") 12 | print() 13 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern134.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows: ") 2 | n = int(input()) 3 | count = 1 4 | for i in range(n): 5 | for j in range(n): 6 | print(count, end=" ") 7 | count+=1 8 | if(count>24): 9 | count-=10 10 | else: 11 | count+=5 12 | 13 | print() 14 | 15 | Enter the no of rows: 16 | 5 17 | 1 2 3 4 5 18 | 11 12 13 14 15 19 | 21 22 23 24 25 20 | 16 17 18 19 20 21 | 26 27 28 29 30 22 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern177.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(height,0,-1): 4 | 5 | for j in range(1,i*2+1): 6 | 7 | if(j <= i): 8 | print(j,end=" ") 9 | 10 | else: 11 | print(i*2 - j + 1,end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # 1 2 3 4 5 5 4 3 2 1 18 | # 1 2 3 4 4 3 2 1 19 | # 1 2 3 3 2 1 20 | # 1 2 2 1 21 | # 1 1 22 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern235.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1, height + 1): 4 | 5 | for j in range(1, height + 1): 6 | 7 | if(i == j or i == height - j + 1): 8 | print(1,end=" ") 9 | 10 | else: 11 | print(0,end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # 1 0 0 0 1 18 | # 0 1 0 1 0 19 | # 0 0 1 0 0 20 | # 0 1 0 1 0 21 | # 1 0 0 0 1 22 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern115.py: -------------------------------------------------------------------------------- 1 | n = 5 2 | for i in range (n): 3 | for j in range (n,i,-1): 4 | print(' ', end=' ') 5 | for k in range(i+1): 6 | if k == 0 or i == n-1: 7 | print('*', end=' ') 8 | else: 9 | print(' ', end=' ') 10 | for m in range (i): 11 | if m == i-1 or i == n-1: 12 | print('*', end=' ') 13 | continue 14 | print(' ', end=' ') 15 | print() 16 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern123.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,height+1): 6 | 7 | if(i == 1 or j = 1 or i == j): 8 | print("*",end=" ") 9 | 10 | else: 11 | print(end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 7 16 | # Output :- 17 | # * * * * * * * 18 | # * * 19 | # * * 20 | # * * 21 | # * * 22 | # * * 23 | # * * 24 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern155.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows:") 2 | n = int(input()) 3 | counter = 2 4 | iterations = 0 5 | spaces = n - 2 6 | for i in range(0, n): 7 | for k in range(0, spaces): 8 | print(" ", end=" ") 9 | for j in range(0, counter): 10 | print("*", end=" ") 11 | iterations = iterations + 1 12 | if iterations % 2 == 0: 13 | counter = counter + 2 14 | spaces = spaces - 2 15 | print() 16 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern159.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows:") 2 | n = int(input()) 3 | counter = 1 4 | iterations = 0 5 | spaces = n//2 6 | for i in range(0, n): 7 | for k in range(0, spaces): 8 | print(" ", end=" ") 9 | for j in range(0, counter): 10 | print("*", end=" ") 11 | iterations = iterations + 1 12 | if iterations % 2 == 0: 13 | counter = counter + 1 14 | spaces = spaces - 1 15 | print() 16 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern75.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1, height+1): 4 | 5 | for j in range(1,height+1): 6 | 7 | if(i == j or i == height-j+1): 8 | print("X",end=" ") 9 | 10 | else : 11 | print("O",end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # X O O O X 18 | # O X O X O 19 | # O O X O O 20 | # O X O X O 21 | # X O O O X 22 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern83.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,height+1): 6 | 7 | if(i == 1 or j == 1 or i == height-j+1): 8 | print("*",end=" ") 9 | 10 | else: 11 | print(end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # * * * * * 18 | # * * 19 | # * * 20 | # * * 21 | # * 22 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern58.py: -------------------------------------------------------------------------------- 1 | 2 | alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 3 | print("Enter the no of rows: ") 4 | n = int(input()) 5 | for i in range(0, n): 6 | for j in range(0, i+1): 7 | print(alpha[i], end=" ") 8 | 9 | for k in range(0,n-i-1): 10 | print("*",end=" ") 11 | print() 12 | 13 | # Enter the no of rows: 14 | # 5 15 | # A * * * * 16 | # B B * * * 17 | # C C C * * 18 | # D D D D * 19 | # E E E E E 20 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern12.py: -------------------------------------------------------------------------------- 1 | # Numeric Pattern 12 2 | 3 | """ 4 | Desired Output: 5 | 6 | 1 10 11 20 21 7 | 2 9 12 19 22 8 | 3 8 13 18 23 9 | 4 7 14 17 24 10 | 5 6 15 16 25 11 | 12 | """ 13 | 14 | x = 9 15 | y = 1 16 | for i in range(1, 6): 17 | print(i, end=" ") 18 | for _ in range(2): 19 | i += x 20 | print(i, end=" ") 21 | i += y 22 | print(i, end=" ") 23 | 24 | x -= 2 25 | y += 2 26 | print() 27 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern170.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | c = 1 3 | 4 | for i in range(1,height+1): 5 | p = 1 6 | 7 | for j in range(1,c+1): 8 | 9 | if(j%2 == 0): 10 | print("*",end=" ") 11 | 12 | else: 13 | print(p,end=" ") 14 | p += 1 15 | 16 | c += 2 17 | print() 18 | 19 | # Sample Input :- 4 20 | # Output :- 21 | # 1 22 | # 1 * 2 23 | # 1 * 2 * 3 24 | # 1 * 2 * 3 * 4 25 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern317.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(0,height): 4 | 5 | for j in range(0,height): 6 | 7 | if(i == 0 or i == height//2 or i == height-1 or j == 0 or j == height-1): 8 | print("*",end=" ") 9 | else: 10 | print(end=" ") 11 | print() 12 | 13 | # Sample Input :- 5 14 | # Output :- 15 | # * * * * * 16 | # * * 17 | # * * * * * 18 | # * * 19 | # * * * * * 20 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern319.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(0,height): 4 | 5 | for j in range(0,height): 6 | 7 | if(i == 0 or j == 0 or i == height-1 or j == height-1 or i == height-j-1): 8 | print("0",end=" ") 9 | else: 10 | print(end=" ") 11 | print() 12 | 13 | # Sample Input :- 5 14 | # Output :- 15 | # 0 0 0 0 0 16 | # 0 0 0 17 | # 0 0 0 18 | # 0 0 0 19 | # 0 0 0 0 0 20 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern61.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | c = 1 3 | 4 | for i in range(height,0,-1) : 5 | 6 | for j in range(1, i+1): 7 | 8 | if(c <= 9): 9 | print("",c,end = " ") 10 | else: 11 | print(c,end = " ") 12 | 13 | c += 1 14 | 15 | print() 16 | 17 | # Sample Input :- 5 18 | # Output :- 19 | # 1 2 3 4 5 20 | # 6 7 8 9 21 | # 10 11 12 22 | # 13 14 23 | # 15 24 | 25 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern14.py: -------------------------------------------------------------------------------- 1 | # Numeric Pattern 12 2 | 3 | """ 4 | Desired Output: 5 | 6 | 1 10 11 20 21 7 | 2 9 12 19 22 8 | 3 8 13 18 23 9 | 4 7 14 17 24 10 | 5 6 15 16 25 11 | 12 | """ 13 | 14 | x = 9 15 | y = 1 16 | for i in range(5, 0, -1): 17 | print(i, end=" ") 18 | for _ in range(2): 19 | i += y 20 | print(i, end=" ") 21 | i += x 22 | print(i, end=" ") 23 | 24 | x -= 2 25 | y += 2 26 | print() 27 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern162.py: -------------------------------------------------------------------------------- 1 | 2 | height = int(input()) 3 | 4 | for i in range(1,height+1): 5 | 6 | for j in range(1,2*height): 7 | 8 | if(i == j or j == height or j == 2*height-i): 9 | print("*",end=" ") 10 | 11 | else: 12 | print(0,end=" ") 13 | 14 | print() 15 | 16 | # Sample Input :- 4 17 | # Output :- 18 | # * 0 0 * 0 0 * 19 | # 0 * 0 * 0 * 0 20 | # 0 0 * * * 0 0 21 | # 0 0 0 * 0 0 0 22 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern35.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | m = 1 3 | n = 1 4 | 5 | for i in range(1,height+1) : 6 | 7 | for j in range(1, i+1): 8 | 9 | if(n <= 9): 10 | print("",n,end = " ") 11 | else: 12 | print(n,end = " ") 13 | n += 2 14 | 15 | print() 16 | 17 | # Sample Input :- 5 18 | # Output :- 19 | # 1 20 | # 3 5 21 | # 7 9 11 22 | # 13 15 17 19 23 | # 21 23 25 27 29 24 | 25 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern77.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1, height+1): 4 | 5 | for j in range(1,height+1): 6 | 7 | if(i == height//2+1 or j == height//2+1): 8 | print("X",end=" ") 9 | 10 | else : 11 | print("O",end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # O O X O O 18 | # O O X O O 19 | # X X X X X 20 | # O O X O O 21 | # O O X O O 22 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern116.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height): 4 | 5 | for j in range(1,i+1): 6 | print(height-j-1,end=" ") 7 | 8 | print() 9 | 10 | for i in range(height-1,0,-1): 11 | 12 | for j in range(height-1,height-i,-1): 13 | print(j-1,end=" ") 14 | 15 | print() 16 | 17 | # Sample Input :- 5 18 | # Output :- 19 | # 3 20 | # 3 2 21 | # 3 2 1 22 | # 3 2 1 0 23 | # 3 2 1 24 | # 3 2 25 | # 3 26 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern117.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height): 4 | 5 | for j in range(height-i,height): 6 | print(j-1,end=" ") 7 | 8 | print() 9 | 10 | for i in range(height-2,0,-1): 11 | 12 | for j in range(height-i,height): 13 | print(j-1,end=" ") 14 | 15 | print() 16 | 17 | # Sample Input :- 5 18 | # Output :- 19 | # 3 20 | # 2 3 21 | # 1 2 3 22 | # 0 1 2 3 23 | # 1 2 3 24 | # 2 3 25 | # 3 26 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern118.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height-1): 4 | 5 | for j in range(1,i+1): 6 | print(j,end=" ") 7 | 8 | print() 9 | 10 | for i in range(height-1,0,-1): 11 | 12 | for j in range(height,height-i,-1): 13 | print(height-j+1,end=" ") 14 | 15 | print() 16 | 17 | # Sample Input :- 5 18 | # Output :- 19 | # 1 20 | # 1 2 21 | # 1 2 3 22 | # 1 2 3 4 23 | # 1 2 3 24 | # 1 2 25 | # 1 26 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern36.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | m = 1 3 | n = 2 4 | 5 | for i in range(1,height+1) : 6 | 7 | for j in range(1, i+1): 8 | 9 | if(n <= 9): 10 | print("",n,end = " ") 11 | else: 12 | print(n,end = " ") 13 | 14 | n += 2 15 | 16 | print() 17 | 18 | # Sample Input :- 5 19 | # Output :- 20 | # 2 21 | # 4 6 22 | # 8 10 12 23 | # 14 16 18 20 24 | # 22 24 26 28 30 25 | 26 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern125.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,height+1): 6 | 7 | if(i == height or j == 1 or i == height-j+1): 8 | print("*",end=" ") 9 | 10 | else: 11 | print(end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 7 16 | # Output :- 17 | # * * 18 | # * * 19 | # * * 20 | # * * 21 | # * * 22 | # * * 23 | # * * * * * * * 24 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern131.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,height+1): 6 | 7 | if(i <= height-j+1 or i == j): 8 | print("*",end=" ") 9 | 10 | else: 11 | print(end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 7 16 | # Output :- 17 | # * * * * * * * 18 | # * * * * * * 19 | # * * * * * 20 | # * * * * 21 | # * * * * 22 | # * * * 23 | # * * 24 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern133.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,height+1): 6 | 7 | if(i == height-j+1 or i >= j): 8 | print("*",end=" ") 9 | 10 | else: 11 | print(end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 7 16 | # Output :- 17 | # * * 18 | # * * * 19 | # * * * * 20 | # * * * * 21 | # * * * * * 22 | # * * * * * * 23 | # * * * * * * * 24 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern76.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1, height+1): 4 | 5 | for j in range(1,height+1): 6 | 7 | if(i == height//2+1 and j == height//2+1): 8 | print("O",end=" ") 9 | 10 | else : 11 | print("X",end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # X X X X X 18 | # X X X X X 19 | # X X O X X 20 | # X X X X X 21 | # X X X X X 22 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern89.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,height//2+2): 6 | 7 | if(i+j == height//2+2 or i-j == height//2): 8 | print("*",end=" ") 9 | 10 | else: 11 | print(end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 7 16 | # Output :- 17 | # * 18 | # * 19 | # * 20 | # * 21 | # * 22 | # * 23 | # * 24 | 25 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern59.py: -------------------------------------------------------------------------------- 1 | 2 | alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 3 | print("Enter the no of rows: ") 4 | n = int(input()) 5 | for i in range(0, n): 6 | for j in range(0, i+1): 7 | print(alpha[j], end=" ") 8 | 9 | for k in range(0,n-i-1): 10 | print("*",end=" ") 11 | print() 12 | 13 | 14 | # Enter the no of rows: 15 | # 5 16 | # A * * * * 17 | # A B * * * 18 | # A B C * * 19 | # A B C D * 20 | # A B C D E 21 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern169.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height): 4 | 5 | for j in range(1,i*2): 6 | 7 | if(j < i): 8 | print(height+j-i,end=" ") 9 | 10 | elif(j == i): 11 | print(0,end=" ") 12 | 13 | else: 14 | print(height-j+i,end=" ") 15 | 16 | print() 17 | 18 | # Sample Input :- 5 19 | # Output :- 20 | # 0 21 | # 4 0 4 22 | # 3 4 0 4 3 23 | # 2 3 4 0 4 3 2 24 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern195.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(i,height): 6 | print(end=" ") 7 | 8 | for j in range(1,i+1): 9 | 10 | if(i%2 == 0): 11 | print("*",end=" ") 12 | 13 | else: 14 | print(i,end=" ") 15 | 16 | print() 17 | 18 | # Sample Input :- 5 19 | # Output :- 20 | # 1 21 | # * * 22 | # 3 3 3 23 | # * * * * 24 | # 5 5 5 5 5 25 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern196.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(height,0,-1): 4 | 5 | for j in range(i,height): 6 | print(end=" ") 7 | 8 | for j in range(1,i+1): 9 | 10 | if(i%2 == 0): 11 | print("*",end=" ") 12 | 13 | else: 14 | print(i,end=" ") 15 | 16 | print() 17 | 18 | # Sample Input :- 5 19 | # Output :- 20 | # 5 5 5 5 5 21 | # * * * * 22 | # 3 3 3 23 | # * * 24 | # 1 25 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern238.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1, height + 1): 4 | 5 | for j in range(1, height + 1): 6 | 7 | if(i == 1 or i == height or j == 1 or j == height): 8 | print(1,end=" ") 9 | 10 | else: 11 | print(end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # 1 1 1 1 1 18 | # 1 1 19 | # 1 1 20 | # 1 1 21 | # 1 1 1 1 1 22 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern250.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,height+1): 6 | 7 | if(i == height or j == height or j == height-i+1): 8 | print(i,end=" ") 9 | 10 | else: 11 | print(end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # 1 18 | # 2 2 19 | # 3 3 20 | # 4 4 21 | # 5 5 5 5 5 22 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern251.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,height+1): 6 | 7 | if(i == height or j == height or j == height-i+1): 8 | print(j,end=" ") 9 | 10 | else: 11 | print(end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # 5 18 | # 4 5 19 | # 3 5 20 | # 2 5 21 | # 1 2 3 4 5 22 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern254.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(height,0,-1): 4 | 5 | for j in range(1,height+1): 6 | 7 | if(i == height or j == height or j == height-i+1): 8 | print(j,end=" ") 9 | 10 | else: 11 | print(end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # 1 2 3 4 5 18 | # 2 5 19 | # 3 5 20 | # 4 5 21 | # 5 22 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpatter203.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | counter = height // 2 3 | for i in range(0, height): 4 | print("*", end="") 5 | for j in range(0, height + 1): 6 | if j == height: 7 | print("*", end="") 8 | elif (i >= height // 2) and (j == counter or j == height - counter - 1): 9 | print("*", end="") 10 | else: 11 | print(end=" ") 12 | if i >= height // 2: 13 | counter = counter + 1 14 | print() 15 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern56.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(height,0,-1): 4 | 5 | for j in range(1,height-i+1): 6 | print(end=" ") 7 | 8 | for j in range(1,i+1): 9 | if(i%2 == 0): 10 | print("*",end=" ") 11 | else: 12 | print("#",end=" ") 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # # # # # # 18 | # * * * * 19 | # # # # 20 | # * * 21 | # # 22 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern85.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,height+1): 6 | 7 | if(i == 1 or j == height or i == j): 8 | print("*",end=" ") 9 | 10 | else: 11 | print(end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # * * * * * 18 | # * * 19 | # * * 20 | # * * 21 | # * 22 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern57.py: -------------------------------------------------------------------------------- 1 | alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 2 | print("Enter the no of rows: ") 3 | n = int(input()) 4 | for i in range(0, n): 5 | nflag = n-i 6 | for j in range(0, i+1): 7 | print(nflag, end=" ") 8 | 9 | for k in range(0,n-i-1): 10 | print(alpha[i],end=" ") 11 | print() 12 | 13 | # Enter the no of rows: 14 | # 5 15 | # 5 A A A A 16 | # 4 4 B B B 17 | # 3 3 3 C C 18 | # 2 2 2 2 D 19 | # 1 1 1 1 1 20 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern80.py: -------------------------------------------------------------------------------- 1 | def pypart2(n): 2 | alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 3 | k = 2*n - 2 4 | flag = n-1 5 | for i in range(0, n): 6 | for j in range(0, k): 7 | print(end=" ") 8 | k = k - 2 9 | for j in range(0, i+1): 10 | if(i%2==0): 11 | print(alpha[i], end=" ") 12 | else: 13 | print(i+1,end=" ") 14 | print("\r"); 15 | 16 | 17 | print("Enter the number of rows: ") 18 | n = int(input()) 19 | pypart2(n) 20 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern253.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(height,0,-1): 4 | 5 | for j in range(1,height+1): 6 | 7 | if(i == height or j == height or j == height-i+1): 8 | print(i,end=" ") 9 | 10 | else: 11 | print(end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # 5 5 5 5 5 18 | # 4 4 19 | # 3 3 20 | # 2 2 21 | # 1 22 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern94.py: -------------------------------------------------------------------------------- 1 | def triangle(n): 2 | k = n - 1 3 | for i in range(0,n): 4 | for j in range(0,k): 5 | print(end = " ") 6 | k -= 1 7 | for j in range (0, i+1): 8 | print(j+1, end=' ') 9 | print("") 10 | 11 | print("Enter the number of rows: ") 12 | n = int(input()) 13 | triangle(n) 14 | 15 | 16 | OUTPUT 17 | 18 | # Enter the number of rows: 19 | # 5 20 | # 1 21 | # 1 2 22 | # 1 2 3 23 | # 1 2 3 4 24 | # 1 2 3 4 5 25 | -------------------------------------------------------------------------------- /Numeric Patterns/numricpattern310.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(0,height): 4 | 5 | for j in range(0,height): 6 | 7 | if(i == height-1 or j == height//2): 8 | print("*",end=" ") 9 | elif(j == height//2-i-1): 10 | print("*",end=" ") 11 | else: 12 | print(end=" ") 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # * * 18 | # * * 19 | # * 20 | # * 21 | # * * * * * 22 | -------------------------------------------------------------------------------- /String Patterns/stringpattern10.py: -------------------------------------------------------------------------------- 1 | print('Enter a string') 2 | pattern_string = input() 3 | print('Enter the number of lines') 4 | lines = int(input()) 5 | index = 0 6 | for i in range (lines) : 7 | for j in range (lines-1, i, -1) : 8 | print(' ', end =' ') 9 | for k in range (i+1) : 10 | try: 11 | print(pattern_string[index], end=' ') 12 | index+= 1 13 | except: 14 | print(pattern_string[0], end=' ') 15 | index = 1 16 | print(end='\n') 17 | -------------------------------------------------------------------------------- /String Patterns/stringpattern12.py: -------------------------------------------------------------------------------- 1 | print('Enter a string') 2 | pattern_string = input() 3 | print('Enter the number of lines') 4 | lines = int(input()) 5 | index = 0 6 | for i in range (lines) : 7 | for j in range (i): 8 | print(' ', end =' ') 9 | for k in range (lines-i) : 10 | try: 11 | print(pattern_string[index], end=' ') 12 | index+= 1 13 | except: 14 | print(pattern_string[0], end=' ') 15 | index = 1 16 | print(end='\n') 17 | 18 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolicpattern104.py: -------------------------------------------------------------------------------- 1 | n = int(input("Number of rows: ")) 2 | k = -1 3 | for i in range(n-1,-1,-1): 4 | for j in range(k,-1,-1): 5 | print(end=" ") 6 | k = k + 2 7 | for j in range(0, i+1): 8 | print("* ", end="") 9 | print("\r") 10 | k = 2 * n - 2 11 | for i in range(1, n): 12 | for j in range(2, k): 13 | print(end=" ") 14 | k = k - 2 15 | for j in range(0, i + 1): 16 | print("* ", end="") 17 | print("\r") -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern79.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(0,height): 4 | 5 | for j in range(0,height): 6 | 7 | if(i == 0 or j == 0 or i == height-1 or j == height-1): 8 | print("*",end=" ") 9 | 10 | else: 11 | print(end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # * * * * * 18 | # * * 19 | # * * 20 | # * * 21 | # * * * * * 22 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern60.py: -------------------------------------------------------------------------------- 1 | alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 2 | print("Enter the no of rows: ") 3 | n = int(input()) 4 | for i in range(0, n): 5 | count = 0 6 | for k in range(0,i+1): 7 | print(alpha[count],end=" ") 8 | count+=1 9 | for j in range(0, n-i-1): 10 | print("*", end=" ") 11 | print() 12 | 13 | # Enter the no of rows: 14 | # 5 15 | # A * * * * 16 | # A B * * * 17 | # A B C * * 18 | # A B C D * 19 | # A B C D E 20 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern97.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1, height+1): 4 | 5 | for j in range(1,height+1): 6 | 7 | if(i == j or i == height-j+1): 8 | c = chr(i + 64) 9 | print(c,end=" ") 10 | 11 | else: 12 | print(end = " ") 13 | 14 | print() 15 | 16 | # Sample Input :- 5 17 | # Output :- 18 | # A A 19 | # B B 20 | # C 21 | # D D 22 | # E E 23 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern98.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1, height+1): 4 | 5 | for j in range(1,height+1): 6 | 7 | if(i == j or i == height-j+1): 8 | c = chr(j + 64) 9 | print(c,end=" ") 10 | 11 | else: 12 | print(end = " ") 13 | 14 | print() 15 | 16 | # Sample Input :- 5 17 | # Output :- 18 | # A E 19 | # B D 20 | # C 21 | # B D 22 | # A E 23 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern189.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(height,0,-1): 4 | 5 | for j in range(1,i): 6 | print(end=" ") 7 | 8 | for j in range(i,height+1): 9 | 10 | if(i%2 == 0): 11 | print("*",end=" ") 12 | 13 | else: 14 | print(j,end=" ") 15 | 16 | print() 17 | 18 | # Sample Input :- 5 19 | # Output :- 20 | # 5 21 | # * * 22 | # 3 4 5 23 | # * * * * 24 | # 1 2 3 4 5 25 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern190.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(i,height): 6 | print(end=" ") 7 | 8 | for j in range(i,0,-1): 9 | 10 | if(j%2 == 0): 11 | print("*",end=" ") 12 | 13 | else: 14 | print(j,end=" ") 15 | 16 | print() 17 | 18 | # Sample Input :- 5 19 | # Output :- 20 | # 1 21 | # * 1 22 | # 3 * 1 23 | # * 3 * 1 24 | # 5 * 3 * 1 25 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern191.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(i,height): 6 | print(end=" ") 7 | 8 | for j in range(i,0,-1): 9 | 10 | if(j%2 == 0): 11 | print("*",end=" ") 12 | 13 | else: 14 | print(i,end=" ") 15 | 16 | print() 17 | 18 | # Sample Input :- 5 19 | # Output :- 20 | # 1 21 | # * 2 22 | # 3 * 3 23 | # * 4 * 4 24 | # 5 * 5 * 5 25 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern192.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(height,0,-1): 4 | 5 | for j in range(i,height): 6 | print(end=" ") 7 | 8 | for j in range(i,0,-1): 9 | 10 | if(i%2 == 0): 11 | print("*",end=" ") 12 | 13 | else: 14 | print(j,end=" ") 15 | 16 | print() 17 | 18 | # Sample Input :- 5 19 | # Output :- 20 | # 5 5 5 5 5 21 | # * * * * 22 | # 3 3 3 23 | # * * 24 | # 1 25 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern194.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(height,0,-1): 4 | 5 | for j in range(i,height): 6 | print(end=" ") 7 | 8 | for j in range(i,0,-1): 9 | 10 | if(j%2 == 0): 11 | print("*",end=" ") 12 | 13 | else: 14 | print(j,end=" ") 15 | 16 | print() 17 | 18 | # Sample Input :- 5 19 | # Output :- 20 | # 5 * 3 * 1 21 | # * 3 * 1 22 | # 3 * 1 23 | # * 1 24 | # 1 25 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern236.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1, height + 1): 4 | 5 | for j in range(1, height + 1): 6 | 7 | if(i == 1 or i == height or j == 1 or j == height): 8 | print(1,end=" ") 9 | 10 | else: 11 | print(0,end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # 1 1 1 1 1 18 | # 1 0 0 0 1 19 | # 1 0 0 0 1 20 | # 1 0 0 0 1 21 | # 1 1 1 1 1 22 | 23 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern239.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1, height + 1): 4 | 5 | for j in range(1, height + 1): 6 | 7 | if(i == 1 or i == height or j == 1 or j == height or i == j): 8 | print(1,end=" ") 9 | 10 | else: 11 | print(end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # 1 1 1 1 1 18 | # 1 1 1 19 | # 1 1 1 20 | # 1 1 1 21 | # 1 1 1 1 1 22 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern243.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | value = 1 3 | 4 | for i in range(1, height + 1): 5 | 6 | for j in range(1,i+1): 7 | 8 | if(i == height or j == 1 or i == j): 9 | print(value,end=" ") 10 | value += 1 11 | 12 | else: 13 | print(end=" ") 14 | 15 | print() 16 | 17 | # Sample Input :- 5 18 | # Output :- 19 | # 1 20 | # 2 3 21 | # 4 5 22 | # 6 7 23 | # 8 9 10 11 12 24 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern246.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | num = 1 3 | 4 | for i in range(1, height + 1): 5 | 6 | for j in range(1, height - i + 2): 7 | 8 | if(i == 1 or j == 1 or j == height - i + 1): 9 | print(height-i+1,end=" ") 10 | 11 | else: 12 | print(end=" ") 13 | 14 | print() 15 | 16 | # Sample Input :- 5 17 | # Output :- 18 | # 5 5 5 5 5 19 | # 4 4 20 | # 3 3 21 | # 2 2 22 | # 1 23 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolicpattern93.py: -------------------------------------------------------------------------------- 1 | n = int(input("Number of rows: ")) 2 | k = 2 * n - 2 3 | for i in range(0,n): 4 | for j in range(0,k): 5 | print(end=" ") 6 | k = k - 1 7 | for j in range(0, i+1): 8 | print("*", end=" ") 9 | print("\r") 10 | k = n - 2 11 | for i in range(n-2, -1 , -1): 12 | for j in range(k , -2 , -1): 13 | print(end=" ") 14 | k = k + 1 15 | for j in range(0, i+1): 16 | print("* " , end="") 17 | print("\r") -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern105.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,2*height): 6 | 7 | if(j <= i or j >= height*2-i): 8 | print("*",end=" ") 9 | 10 | else: 11 | print(end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # * * 18 | # * * * * 19 | # * * * * * * 20 | # * * * * * * * * 21 | # * * * * * * * * * 22 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern182.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | width = 2 * height - 1 3 | half = height // 2 4 | 5 | for i in range(0, height): 6 | print("*", end="") 7 | for j in range(0, width): 8 | if (i == 0 or i == height - 1 or i == half) and j < (width - 2): 9 | print("*", end="") 10 | elif j == (width - 2) and not (i == 0 or i == height - 1 or i == half): 11 | print("*", end="") 12 | else: 13 | print(end=" ") 14 | print() 15 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern201.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | for i in range(0, height): 3 | if i != 0 and i != height - 1: 4 | print("*", end="") 5 | else: 6 | print(end=" ") 7 | for j in range(0, height): 8 | if (i == height - 1) and j >= 0 and j < height - 1: 9 | print("*", end="") 10 | elif j == height - 1 and i != 0 and i != height - 1: 11 | print("*", end="") 12 | else: 13 | print(end=" ") 14 | print() 15 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern80.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(0,height): 4 | 5 | for j in range(0,height): 6 | 7 | if(i == 0 or j == 0 or i == height-1 or j == height-1): 8 | print("*",end=" ") 9 | 10 | else: 11 | print("#",end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # * * * * * 18 | # * # # # * 19 | # * # # # * 20 | # * # # # * 21 | # * * * * * 22 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern84.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,height+1): 6 | 7 | if(i == height or j == height or i == height-j+1): 8 | print("*",end=" ") 9 | 10 | else: 11 | print(end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 5 16 | # Output :- 17 | # * 18 | # * * 19 | # * * 20 | # * * 21 | # * * * * * 22 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern162.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | counter = height // 2 3 | for i in range(0, height): 4 | print("*", end="") 5 | for j in range(0, height+1): 6 | if (j == height): 7 | print("*", end="") 8 | elif ((i >= height // 2) and (j == counter or j == height - counter - 1)): 9 | print("*", end="") 10 | else: 11 | print(end=" ") 12 | if(i >= height // 2): 13 | counter = counter + 1 14 | print() 15 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern188.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | counter = height // 2 3 | for i in range(0, height): 4 | print("W", end="") 5 | for j in range(0, height+1): 6 | if (j == height): 7 | print("W", end="") 8 | elif ((i >= height // 2) and (j == counter or j == height - counter - 1)): 9 | print("W", end="") 10 | else: 11 | print(end=" ") 12 | if(i >= height // 2): 13 | counter = counter + 1 14 | print() 15 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern61.py: -------------------------------------------------------------------------------- 1 | 2 | alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 3 | print("Enter the no of rows: ") 4 | n = int(input()) 5 | for i in range(0, n): 6 | count = 0 7 | for k in range(0,n-i): 8 | print(alpha[count],end=" ") 9 | count+=1 10 | for j in range(0, i): 11 | print("*", end=" ") 12 | print() 13 | 14 | # Enter the no of rows: 15 | # 5 16 | # A B C D E 17 | # A B C D * 18 | # A B C * * 19 | # A B * * * 20 | # A * * * * 21 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern187.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(0,height-i): 6 | print(end=" ") 7 | 8 | for j in range(i,0,-1): 9 | 10 | if(i%2 == 0): 11 | print("*",end=" ") 12 | 13 | else: 14 | print(i,end=" ") 15 | 16 | print() 17 | 18 | # Sample Input :- 5 19 | # Output :- 20 | # 1 21 | # * * 22 | # 3 3 3 23 | # * * * * 24 | # 5 5 5 5 5 25 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern188.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(0,height-i): 6 | print(end=" ") 7 | 8 | for j in range(i,0,-1): 9 | 10 | if(i%2 == 0): 11 | print("*",end=" ") 12 | 13 | else: 14 | print(j,end=" ") 15 | 16 | print() 17 | 18 | # Sample Input :- 5 19 | # Output :- 20 | # 1 21 | # * * 22 | # 3 2 1 23 | # * * * * 24 | # 5 4 3 2 1 25 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern193.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(height,0,-1): 4 | 5 | for j in range(i,height): 6 | print(end=" ") 7 | 8 | for j in range(i,0,-1): 9 | 10 | if(i%2 == 0): 11 | print("*",end=" ") 12 | 13 | else: 14 | print(j,end=" ") 15 | 16 | print() 17 | 18 | # Sample Input :- 5 19 | # Output :- 20 | # 5 4 3 2 1 21 | # * * * * 22 | # 3 2 1 23 | # * * 24 | # 1 25 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern262.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,height//2+2): 6 | 7 | if(i+j == height//2+2 or i-j == height//2): 8 | print(i,end=" ") 9 | 10 | else: 11 | print(end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 7 16 | # Output :- 17 | # 1 18 | # 2 19 | # 3 20 | # 4 21 | # 5 22 | # 6 23 | # 7 24 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolicpattern36.py: -------------------------------------------------------------------------------- 1 | print("Enter the no of rows: ") 2 | a = int(input()) 3 | counter = 1 4 | for i in range(0, a): 5 | n = counter + i 6 | if i % 2 == 1: 7 | counter = n 8 | for j in range(0, i + 1): 9 | if i % 2 == 0: 10 | print(str(counter) + "#", end=" ") 11 | counter += 1 12 | else: 13 | print(str(counter) + "#", end=" ") 14 | counter = counter - 1 15 | counter = n + 1 16 | print() 17 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern132.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,height+1): 6 | 7 | if(i == height-j+1 or i <= j): 8 | print("*",end=" ") 9 | 10 | else: 11 | print(end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 7 16 | # Output :- 17 | # * * * * * * * 18 | # * * * * * * 19 | # * * * * * 20 | # * * * * 21 | # * * * * 22 | # * * * 23 | # * * 24 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern100.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1, height+1): 4 | 5 | for j in range(1,height+1): 6 | 7 | if(i == j or i == height-j+1): 8 | c = chr(height - j + 65) 9 | print(c,end=" ") 10 | 11 | else: 12 | print(end = " ") 13 | 14 | print() 15 | 16 | # Sample Input :- 5 17 | # Output :- 18 | # E A 19 | # D B 20 | # C 21 | # D B 22 | # E A 23 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern141.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | width = 2 * height - 1 3 | half = height // 2 4 | 5 | for i in range(0, height): 6 | print("*", end="") 7 | for j in range(0, width): 8 | if (i == 0 or i == height - 1 or i == half) and j < (width - 2): 9 | print("*", end="") 10 | elif j == (width - 2) and not (i == 0 or i == height - 1 or i == half): 11 | print("*", end="") 12 | else: 13 | print(end=" ") 14 | print() 15 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern167.py: -------------------------------------------------------------------------------- 1 | height = 5 2 | width = 2 * height - 1 3 | half = height // 2 4 | 5 | for i in range(0, height): 6 | print("*", end="") 7 | for j in range(0, width): 8 | if (i == 0 or i == height - 1 or i == half) and j < (width - 2): 9 | print("B", end="") 10 | elif j == (width - 2) and not (i == 0 or i == height - 1 or i == half): 11 | print("B", end="") 12 | else: 13 | print(end=" ") 14 | print() 15 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern63.py: -------------------------------------------------------------------------------- 1 | 2 | alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 3 | print("Enter the no of rows: ") 4 | n = int(input()) 5 | for i in range(0, n): 6 | for k in range(0,n-i-1): 7 | print("*",end=" ") 8 | count = i 9 | for j in range(0, i+1): 10 | print(alpha[count], end=" ") 11 | count-=1 12 | print() 13 | 14 | # Enter the no of rows: 15 | # 5 16 | # * * * * A 17 | # * * * B A 18 | # * * C B A 19 | # * D C B A 20 | # E D C B A 21 | -------------------------------------------------------------------------------- /Alphabetic Patterns/alphabeticpattern99.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1, height+1): 4 | 5 | for j in range(1,height+1): 6 | 7 | if(i == j or i == height-j+1): 8 | c = chr(height - i + 65) 9 | print(c,end=" ") 10 | 11 | else: 12 | print(end = " ") 13 | 14 | print() 15 | 16 | # Sample Input :- 5 17 | # Output :- 18 | # E E 19 | # D D 20 | # C 21 | # B B 22 | # A A 23 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern245.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | num = 1 3 | 4 | for i in range(1, height + 1): 5 | 6 | for j in range(height,0,-1): 7 | 8 | if(i == height or j == height or i == height-j+1): 9 | print(j,end=" ") 10 | 11 | else: 12 | print(end=" ") 13 | 14 | print() 15 | 16 | # Sample Input :- 5 17 | # Output :- 18 | # 5 19 | # 5 4 20 | # 5 3 21 | # 5 2 22 | # 5 4 3 2 1 23 | -------------------------------------------------------------------------------- /Numeric Patterns/numericpattern93.py: -------------------------------------------------------------------------------- 1 | def triangle(n): 2 | k = n - 1 3 | for i in range(0,n): 4 | for j in range(0,k): 5 | print(end = " ") 6 | k -= 1 7 | for j in range (0, i+1): 8 | print(i+1, end=' ') 9 | print("") 10 | 11 | print("Enter the number of rows: ") 12 | n = int(input()) 13 | triangle(n 14 | 15 | 16 | # OUTPUT 17 | # Enter the number of rows: 18 | # 5 19 | # 1 20 | # 2 2 21 | # 3 3 3 22 | # 4 4 4 4 23 | # 5 5 5 5 5 24 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolicpattern50.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | spaces = n 4 | counter = 1 5 | c = 0 6 | for i in range(0, n): 7 | c = i + 1 8 | for k in range(0, spaces): 9 | print(" ", end=" ") 10 | for j in range(0, counter): 11 | if c % 2 == 0: 12 | print("*", end=" ") 13 | else: 14 | print("#", end=" ") 15 | c = c + 1 16 | counter = counter + 1 17 | print() 18 | spaces = spaces - 1 19 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolicpattern51.py: -------------------------------------------------------------------------------- 1 | print("Enter the number of rows: ") 2 | n = int(input()) 3 | spaces = n 4 | counter = 1 5 | c = 0 6 | for i in range(0, n): 7 | c = i + 1 8 | for k in range(0, spaces): 9 | print(" ", end=" ") 10 | for j in range(1, counter+1): 11 | if i % 2 != 0: 12 | print("*", end=" ") 13 | else: 14 | print(c, end=" ") 15 | c = c - 1 16 | counter = counter + 1 17 | print() 18 | spaces = spaces - 1 19 | -------------------------------------------------------------------------------- /Symbol Patterns/symbolpattern139.py: -------------------------------------------------------------------------------- 1 | height = int(input()) 2 | 3 | for i in range(1,height+1): 4 | 5 | for j in range(1,height+1): 6 | 7 | if(i == 1 or i == height or i == j or i == height-j+1): 8 | print("*",end=" ") 9 | 10 | else: 11 | print(end=" ") 12 | 13 | print() 14 | 15 | # Sample Input :- 7 16 | # Output :- 17 | # * * * * * * * 18 | # * * 19 | # * * 20 | # * 21 | # * * 22 | # * * 23 | # * * * * * * * 24 | --------------------------------------------------------------------------------