- ➤ Print half pyramid pattern's .
- # number of rows
- rows = 5
- for i in range(0, rows):
- # nested loop for each column
- for j in range(0, i + 1):
- # print star
- print("*", end=' ')
- # new line after each row
- print("\r")
- OUTPUT :
- *
- * *
- * * *
- * * * *
- * * * * *
- ➤ Print triangle pyramid of star .
- # number of rows
- rows = 5
- k = 2 * rows - 2
- for i in range(0, rows):
- # process each column
- for j in range(0, k):
- # print space in pyramid
- print(end=" ")
- k = k - 2
- for j in range(0, i + 1):
- # display star
- print("* ", end="")
- print("")
- OUTPUT :
- *
- * *
- * * *
- * * * *
- * * * * *
- ➤ Print downward half pyramid pattern of star's.
- rows = 5
- for i in range(rows + 1, 0, -1):
- # nested reverse loop
- for j in range(0, i - 1):
- # display star
- print("*", end=' ')
- print(" ")
- OUTPUT :
- * * * * *
- * * * *
- * * *
- * *
- *
- ➤ Print downward full pyramid pattern of star .
- rows = 5
- k = 2 * rows - 2
- for i in range(rows, -1, -1):
- for j in range(k, 0, -1):
- print(end=" ")
- k = k + 1
- for j in range(0, i + 1):
- print("*", end=" ")
- print("")
- OUTPUT :
- * * * * * *
- * * * * *
- * * * *
- * * *
- * *
- *
- ➤ Print equilateral triangle pattern of star .
- print("Print equilateral triangle Pyramid using asterisk symbol ")
- # printing full Triangle pyramid using stars
- size = 7
- m = (2 * size) - 2
- for i in range(0, size):
- for j in range(0, m):
- print(end=" ")
- # decrementing m after each loop
- m = m - 1
- for j in range(0, i + 1):
- print("* ", end=' ')
- print(" ")
- OUTPUT :
- *
- * *
- * * *
- * * * *
- * * * * *
- * * * * * *
- * * * * * * *
- ➤ Print Right start pattern of star .
- rows = 5
- for i in range(0, rows):
- for j in range(0, i + 1):
- print("*", end=' ')
- print("\r")
- for i in range(rows, 0, -1):
- for j in range(0, i - 1):
- print("*", end=' ')
- print("\r")
- OUTPUT :
- *
- * *
- * * *
- * * * *
- * * * * *
- * * * *
- * * *
- * *
- *
- ➤ Print the number's pattern .
- rows = 6
- # if you want user to enter a number, uncomment the below line
- # rows = int(input('Enter the number of rows'))
- # outer loop
- for i in range(rows):
- # nested loop
- for j in range(i):
- # display number
- print(i, end=' ')
- # new line after each row
- print('')
- OUTPUT :
- 1
- 2 2
- 3 3 3
- 4 4 4 4
- 5 5 5 5 5
- ➤ Print Number's in pyramid pattern .
- rows = 5
- for i in range(1, rows + 1):
- for j in range(1, i + 1):
- print(j, end=' ')
- print('')
- OUTPUT :
- 1
- 1 2
- 1 2 3
- 1 2 3 4
- 1 2 3 4 5
- ➤ Print Inverted pyramid pattern of number's .
- rows = 5
- b = 0
- # reverse for loop from 5 to 0
- for i in range(rows, 0, -1):
- b += 1
- for j in range(1, i + 1):
- print(b, end=' ')
- print('\r')
- OUTPUT :
- 1 1 1 1 1
- 2 2 2 2
- 3 3 3
- 4 4
- 5
- ➤ Print the inverted pyramid pattern with the same digit .
- rows = 5
- num = rows
- # reverse for loop
- for i in range(rows, 0, -1):
- for j in range(0, i):
- print(num, end=' ')
- print("\r")
- OUTPUT :
- 5 5 5 5 5
- 5 5 5 5
- 5 5 5
- 5 5
- 5
- ➤ Print inverted pyramid pattern with different digit .
- rows = 5
- for i in range(rows, 0, -1):
- for j in range(0, i + 1):
- print(j, end=' ')
- print("\r")
- OUTPUT :
- 0 1 2 3 4 5
- 0 1 2 3 4
- 0 1 2 3
- 0 1 2
- 0 1
- ➤ Print reverse number pattern's .
- rows = 5
- # reverse loop
- for i in range(rows, 0, -1):
- num = i
- for j in range(0, i):
- print(num, end=' ')
- print("\r")
- OUTPUT :
- 5 5 5 5 5
- 4 4 4 4
- 3 3 3
- 2 2
- 1
- ➤ Print Reverse pyramid of umber's .
- rows = 6
- for i in range(1, rows):
- for j in range(i, 0, -1):
- print(j, end=' ')
- print("")
- OUTPUT :
- 1
- 2 1
- 3 2 1
- 4 3 2 1
- 5 4 3 2 1
- ➤ Print Another reverse number pattern .
- rows = 5
- for i in range(0, rows + 1):
- for j in range(rows - i, 0, -1):
- print(j, end=' ')
- print()
- OUTPUT :
- 5 4 3 2 1
- 4 3 2 1
- 3 2 1
- 2 1
- 1
- ➤ Print square pattern with number's.
- rows = 5
- for i in range(1, rows + 1):
- for j in range(1, rows + 1):
- if j <= i:
- print(i, end=' ')
- else:
- print(j, end=' ')
- print()
- OUTPUT :
- 1 2 3 4 5
- 2 2 3 4 5
- 3 3 3 4 5
- 4 4 4 4 5
- 5 5 5 5 5
- ➤ Print Multliplication table using number's pattern .
- rows = 10
- # rows = int(input("Enter the number of rows "))
- for i in range(1, rows + 1):
- for j in range(1, i + 1):
- # multiplication current column and row
- square = i * j
- print(i * j, end=' ')
- print()
- OUTPUT :
- 1
- 2 4
- 3 6 9
- 4 8 12 16
- 5 10 15 20 25
- 6 12 18 24 30 36
- 7 14 21 28 35 42 49
- 8 16 24 32 40 48 56 64
- 9 18 27 36 45 54 63 72 81
- 10 20 30 40 50 60 70 80 90 100
- ➤ Print Daimond shaped pattern of star's .
- rows = 5
- k = 2 * rows - 2
- for i in range(0, rows):
- for j in range(0, k):
- print(end=" ")
- k = k - 1
- for j in range(0, i + 1):
- print("* ", end="")
- print("")
- k = rows - 2
- for i in range(rows, -1, -1):
- for j in range(k, 0, -1):
- print(end=" ")
- k = k + 1
- for j in range(0, i + 1):
- print("* ", end="")
- print("")
- OUTPUT :
- *
- * *
- * * *
- * * * *
- * * * * *
- * * * * * *
- * * * * *
- * * * *
- * * *
- * *
- *
- ➤ Print Daimond shaped pattern of star's .
- rows = 5
- i = 1
- while i <= rows:
- j = rows
- while j > i:
- # display space
- print(' ', end=' ')
- j -= 1
- print('*', end=' ')
- k = 1
- while k < 2 * (i - 1):
- print(' ', end=' ')
- k += 1
- if i == 1:
- print()
- else:
- print('*')
- i += 1
- i = rows - 1
- while i >= 1:
- j = rows
- while j > i:
- print(' ', end=' ')
- j -= 1
- print('*', end=' ')
- k = 1
- while k <= 2 * (i - 1):
- print(' ', end=' ')
- k += 1
- if i == 1:
- print()
- else:
- print('*')
- i -= 1
- OUTPUT :
- *
- * *
- * *
- * *
- * *
- * *
- * *
- * *
- *
- ➤ Pattern to display letter of the word .
- word = "Python"
- x = ""
- for i in word:
- x += i
- print(x)
- OUTPUT :
- P
- Py
- Pyt
- Pyth
- Pytho
- Python
- ➤ Print Equilateral triangle pattern of character's /alphabet's.
- print("Print equilateral triangle Pyramid with characters ")
- size = 7
- asciiNumber = 65
- m = (2 * size) - 2
- for i in range(0, size):
- for j in range(0, m):
- print(end=" ")
- m = m - 1
- for j in range(0, i + 1):
- character = chr(asciiNumber)
- print(character, end=' ')
- asciiNumber += 1
- print(" ")
- OUTPUT :
- A
- B C
- D E F
- G H I J
- K L M N O
- P Q R S T U
- V W X Y Z [ \
- ➤ Print Random number pattern's.
- rows = 9
- for i in range(1, rows):
- for i in range(0, i, 1):
- print(format(2 ** i, "4d"), end=' ')
- for i in range(-1 + i, -1, -1):
- print(format(2 ** i, "4d"), end=' ')
- print("")
- OUTPUT :
- 1
- 1 2 1
- 1 2 4 2 1
- 1 2 4 8 4 2 1
- 1 2 4 8 16 8 4 2 1
- 1 2 4 8 16 32 16 8 4 2 1
- 1 2 4 8 16 32 64 32 16 8 4 2 1
- 1 2 4 8 16 32 64 128 64 32 16 8 4 2 1
- Go to Link
Using Python to print the pattern .
Please wait 0 seconds...
Scroll Down and click on Go to Link for destination
Congrats! Link is Generated