Python Star Pattern Example : 1
*
* *
* * *
* * * *
* * * * *
1 2 3 4 5 6 | for i in range(0, 5): for j in range(0, i+1): print("* ",end="") print() |
Python Star Pattern Example : 2
*
* * *
* * * * *
* * * * * * *
* * * * * * * * *
1 2 3 4 5 6 7 8 | k = 1 for i in range(0, 5): for j in range(0, k): print("* ", end="") k = k + 2 print() |
Python Star Pattern Example : 3
1 2 3 4 5 6 7 8 9 10 | k = 8 for i in range(0, 5): for j in range(0, k): print(end=" ") k = k - 2 for j in range(0, i+1): print("* ", end="") print() |
Python Star Pattern Example : 4
1 2 3 4 5 6 7 8 9 10 11 12 | k = 16 tim = 1 for i in range(0, 5): for j in range(0, k): print(end=" ") k = k - 4 for j in range(0, tim): print("* ", end="") tim = tim + 2 print() |
Python Star Pattern Example: 5
1 2 3 4 5 6 7 8 9 10 11 12 | k = 0 rows = 5 for i in range(1, rows+1): for space in range(1, (rows-i)+1): print(end=" ") while k != (2*i-1): print("* ", end="") k = k + 1 k = 0 print() |
Python Star Pattern Example: 6
* * * * *
* * * *
* * *
* *
*
1 2 3 4 5 6 | for i in range(0, 5): for j in range(5, i, -1): print("* ", end="") print() |
Python Star Pattern Example: 7
*
* *
* * *
* * * *
* * * * *
* * * *
* * *
* *
*
1 2 3 4 5 6 7 8 9 10 11 12 | n=5; for i in range(n): for j in range(i): print ('* ', end="") print('') for i in range(n,0,-1): for j in range(i): print('* ', end="") print('') |
Python Star Pattern Example: 8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | n=5; for i in range(0,n+1): for j in range(0,n-i): print(end=" ") for j in range(0,i): print("*",end=" ") print() if i==n: for i in range(n-1,0,-1): for j in range(0,n-i): print(end=" ") for j in range(0,i): print("*",end=" ") print() |
Python Star Pattern Example: 9
1 2 3 4 | for e in range (5,0,-1): print((5-e) * ' ' + e * '*') |
Python Star Pattern Example: 10
1 2 3 4 | for g in range (6,0,-1): print(g * ' ' + (6-g) * '*') |
Python Star Pattern Example: 11
1 2 3 4 5 6 7 8 9 | for row in range(1,5): for col in range(1,8): if (row==4 or row+col==5 or col-row==3): print("*",end="") else: print(" ",end="") print() |
Python Star Pattern Example: 12
1 2 3 4 5 6 7 8 9 10 | n=5; for r in range(0,n): for c in range(0,n): if r==0 or c==(n-1) or r==c: print("*",end="") else: print(end=" ") print() |
Python Star Pattern Example 13 : ‘A’ Pattern in Python
1 2 3 4 5 6 7 8 9 10 11 | result_str=""; for row in range(0,7): for column in range(0,7): if (((column == 1 or column == 5) and row != 0) or ((row == 0 or row == 3) and (column > 1 and column < 5))): result_str=result_str+"*" else: result_str=result_str+" " result_str=result_str+"\n" print(result_str); |
Python Star Pattern Example 14 : ‘D’ Pattern in Python
1 2 3 4 5 6 7 8 9 10 11 | result_str=""; for row in range(0,7): for column in range(0,7): if (column == 1 or ((row == 0 or row == 6) and (column > 1 and column < 5)) or (column == 5 and row != 0 and row != 6)): result_str=result_str+"*" else: result_str=result_str+" " result_str=result_str+"\n" print(result_str); |
Python Star Pattern Example 15 : ‘E’ Pattern in Python
1 2 3 4 5 6 7 8 9 10 11 | result_str=""; for row in range(0,7): for column in range(0,7): if (column == 1 or ((row == 0 or row == 6) and (column > 1 and column < 6)) or (row == 3 and column > 1 and column < 5)): result_str=result_str+"*" else: result_str=result_str+" " result_str=result_str+"\n" print(result_str); |
Python Star Pattern Example 16 : ‘G’ Pattern in Python
1 2 3 4 5 6 7 8 9 10 11 | result_str=""; for row in range(0,7): for column in range(0,7): if ((column == 1 and row != 0 and row != 6) or ((row == 0 or row == 6) and column > 1 and column < 5) or (row == 3 and column > 2 and column < 6) or (column == 5 and row != 0 and row != 2 and row != 6)): result_str=result_str+"*" else: result_str=result_str+" " result_str=result_str+"\n" print(result_str); |
Python Star Pattern Example 17 : ‘L’ Pattern in Python
*
*
*
*
*
*
* * * * *
1 2 3 4 5 6 7 8 9 10 11 | result_str=""; for row in range(0,7): for column in range(0,7): if (column == 1 or (row == 6 and column != 0 and column < 6)): result_str=result_str+"*" else: result_str=result_str+" " result_str=result_str+"\n" print(result_str); |
Python Star Pattern Example 18 : ‘M’ Pattern in Python
1 2 3 4 5 6 7 8 9 10 11 | result_str=""; for row in range(0,7): for column in range(0,7): if (column == 1 or column == 5 or (row == 2 and (column == 2 or column == 4)) or (row == 3 and column == 3)): result_str=result_str+"* " else: result_str=result_str+" " result_str=result_str+"\n" print(result_str); |
Python Star Pattern Example 19 : ‘O’ Pattern in Python
1 2 3 4 5 6 7 8 9 10 11 | result_str=""; for row in range(0,7): for column in range(0,7): if (((column == 1 or column == 5) and row != 0 and row != 6) or ((row == 0 or row == 6) and column > 1 and column < 5)): result_str=result_str+"*" else: result_str=result_str+" " result_str=result_str+"\n" print(result_str); |
Python Star Pattern Example 20 : ‘P’ Pattern in Python
1 2 3 4 5 6 7 8 9 10 11 | result_str=""; for row in range(0,7): for column in range(0,7): if (column == 1 or ((row == 0 or row == 3) and column > 0 and column < 5) or ((column == 5 or column == 1) and (row == 1 or row == 2))): result_str=result_str+"*" else: result_str=result_str+" " result_str=result_str+"\n" print(result_str); |
Python Star Pattern Example 21 : ‘X’ Pattern in Python
1 2 3 4 5 6 7 8 9 10 11 | result_str=""; for row in range(0,7): for column in range(0,7): if (((column == 1 or column == 5) and (row > 4 or row < 2)) or row == column and column > 0 and column < 6 or (column == 2 and row == 4) or (column == 4 and row == 2)): result_str=result_str+"*" else: result_str=result_str+" " result_str=result_str+"\n" print(result_str); |
Python Star Pattern Example 22 : ‘Z’ Pattern in Python
1 2 3 4 5 6 7 8 9 10 11 | result_str=""; for row in range(0,7): for column in range(0,7): if (((row == 0 or row == 6) and column >= 0 and column <= 6) or row+column==6): result_str=result_str+"*" else: result_str=result_str+" " result_str=result_str+"\n" print(result_str); |