There are also other types of patterns that do not use stars but numbers or alphabets. We will also look at these in brief here. Show
Let's start with different pattern programs using python. List of Pattern Program In PythonWe are going to see the following pattern program in python here in this article. 1. Square Pattern in Python***** ***** ***** ***** ***** The square pattern is the easiest pattern program. It is a pattern that has the shape of a square made of stars. Let's see how to create and print a square pattern.
Output: ***** ***** ***** ***** ***** 2. Hollow Square Pattern***** * * * * * * ***** The hollow square pattern is a bit more difficult pattern program than a simple square because here you will have to deal with spaces within the square. Here are the steps to create a hollow square pattern.
Output: ***** * * * * * * ***** 3. Left Triangle Star Pattern In Python* ** *** **** ***** The left triangle star pattern is a star pattern in the shape of a triangle. It is quite easy to create it. Steps to create a left triangle star pattern:
0Output: * ** *** **** ***** report this ad 4. Right Triangle Star Pattern In Python 2The right triangle star pattern is a star pattern in the shape of a triangle as shown above. It is similar to the left triangle star pattern but you will have to deal with spaces. Steps to create a right triangle star pattern:
3 4Output: 25. Left Downward Triangle Pattern 6The left downward triangle pattern is the star pattern of a triangle upside down. It is very easy to create. Run 2 nested loops where the internal loop will run size - i times and external loop will run size times. Here i is the current row.
7 8Output: 66. Right Downward Triangle Pattern 0The right downward triangle pattern is a pattern that is upside down and has perpendicular to the right side. Steps to create a right downward triangle pattern:
1Output: 07. Hollow triangle star Pattern 3The hollow triangle star pattern is a star pattern in the shape of the triangle made of stars but hollow. Follow these steps:
4Output: 38. Pyramid Pattern in python 6The pyramid pattern is a very famous pattern in programming. It has the shape of an equilateral triangle and it is used to represent a pyramid. You can see the pattern up here. The pyramid pattern has an odd number of stars in each row 1, 3, 5, 7, etc.
7 8Output: 69. Hollow Pyramid Pattern In Python***** ***** ***** ***** *****0 The hollow pyramid pattern is a pyramid pattern made of stars but hollow. You can see the pattern up there. Follow these steps to create hollow pyramid pattern:
***** ***** ***** ***** *****1 Output: ***** ***** ***** ***** *****0 10. Reverse Pyramid Pattern In Python***** ***** ***** ***** *****3 The reverse pyramid pattern is the same as the pyramid pattern but it is upside down. See the pattern up there. Just like the pyramid pattern, the reverse pyramid pattern follows the same logic. The only difference is that we have to print the spaces and stars with reverse logic. ***** ***** ***** ***** *****4 Output: ***** ***** ***** ***** *****3 Stay Ahead, Learn More
11. Diamond Star Pattern In Python***** ***** ***** ***** *****6 The diamond star pattern is a star pattern with the shape of the diamond. You can see the pattern up here. If you look closely, you will see that the pattern is a combination of a pyramid pattern and a downward triangle star pattern. So you can create this pattern by combining both patterns. Here is the code to create this pattern. ***** ***** ***** ***** *****7 Output: ***** ***** ***** ***** *****6 12. Hollow Diamond Star Pattern In Python***** ***** ***** ***** *****9 The hollow diamond pattern is the same as the diamond star pattern but hollow. The pattern is up here. This one is complex because you have to deal with multiple things like spaces, stars for each row where the pattern itself is divided into two parts upper pyramid and lower pyramid. Let's see the code. ***** * * * * * * *****0 Output: ***** ***** ***** ***** *****9 13. Hourglass Star Pattern In Python***** * * * * * * *****2 The hourglass pattern is a pattern with the shape of an hourglass. When you observe the pattern, you will see that it is made up of two patterns. The first pattern is a downward pyramid pattern and the second pattern is an upward triangle pattern. You can create this pattern by combining both patterns. The code is as follows. ***** * * * * * * *****3 Output: ***** * * * * * * *****2 14. Right Pascal Star Pattern In Python***** * * * * * * *****5 The right pascal triangle pattern is shown above. It can be clearly seen that it is made up of an upper triangle and a lower triangle. So you can run 2 different loops one which creates the upper triangle and another which creates the lower triangle. Here is the complete code.
***** * * * * * * *****6 ***** * * * * * * *****7 Output: ***** * * * * * * *****5 15. Left Pascal Star Pattern In Python***** * * * * * * *****9 The left pascal triangle pattern is a mirror image of the right pascal triangle pattern. The pattern is shown above. The left pascal triangle pattern is a little bit more complicated than the right pascal triangle pattern because you will have to deal with both spaces and stars. Let's see the code. 0Output: ***** * * * * * * *****9 16. Heart pattern in python 2The heart pattern is a pattern with the shape of a heart. It is quite a complex pattern. But if you observe the code carefully then you will understand it easily. 3Output: 217. Plus pattern program in PythonThe plus pattern is a pattern with the shape of a plus sign (+). 5The complete code is given below. 6Output: 718. Cross pattern program in PythonThe cross pattern is a pattern with the shape of a cross sign (X). 8Here is the complete code to create the cross pattern. 9Output: 819. Left Number Triangle Pattern ProgramThe left number triangle pattern is a triangle pattern that is made of numbers and has perpendicular on its left side. 1The complete code for the left number triangle pattern is given below. 2Output: 120. Right Number Triangle Pattern ProgramThe right number triangle pattern is a triangle pattern that is made of numbers and has perpendicular on its right side. 4The complete code for the right number triangle pattern is given below. 5Output: 421. Number Pyramid Pattern Program In PythonThe number pyramid pattern is a pattern that is made of numbers and has a pyramid shape. 7The complete code for the number pyramid pattern is given below. 8Output: 722. Reverse Number Pyramid Pattern Program In PythonThe reverse number pyramid pattern is a number pyramid reversed 180 degrees. ***** * * * * * * *****0 The complete code for the reverse number pyramid pattern is given below. ***** * * * * * * *****1 Output: ***** * * * * * * *****0 23. Hollow Number Pyramid Pattern ProgramThe hollow number pyramid pattern is a number pyramid pattern that has a hollow space in the middle. ***** * * * * * * *****3 The complete code for the hollow number pyramid pattern is given below. ***** * * * * * * *****4 Output: ***** * * * * * * *****3 24. Number Diamond Pattern ProgramThe number diamond pattern is a diamond pattern that is made of numbers. ***** * * * * * * *****6 The complete code for the number diamond pattern is given below. ***** * * * * * * *****7 Output: ***** * * * * * * *****6 25. Hollow Number Diamond Pattern ProgramThe hollow number diamond pattern is a diamond pattern that is made of numbers and is hollow inside. ***** * * * * * * *****9 The complete code for the hollow number diamond pattern is given below. * ** *** **** *****0 Output: ***** * * * * * * *****9 Let's now create some pattern programs using alphabets instead of stars or numbers. 26. Alphabet Pyramid Pattern ProgramThe alphabet pyramid pattern is a pyramid pattern that is made of alphabets. * ** *** **** *****2 The complete code for the alphabet pyramid pattern is given below. * ** *** **** *****3 Output: * ** *** **** *****2 27. Reverse Alphabet Pyramid Pattern ProgramThe reverse alphabet pyramid pattern is a pyramid pattern that is made of alphabets and is upside down. * ** *** **** *****5 The complete code for the reverse alphabet pyramid pattern is given below. * ** *** **** *****6 Output: * ** *** **** *****5 28. Hollow Alphabet Pyramid PatternThe hollow alphabet pyramid pattern is a pyramid pattern that is made of alphabets and is hollow inside. * ** *** **** *****8 The complete code for the hollow alphabet pyramid pattern is given below. * ** *** **** *****9 Output: * ** *** **** *****8 29. Alphabet Diamond Pattern ProgramThe alphabet diamond pattern is a diamond pattern that is made of alphabets. 1The complete code for the alphabet diamond pattern is given below. 2Output: 130. Hollow Alphabet Diamond PatternThe hollow alphabet diamond pattern is a diamond pattern that is made of alphabets and is hollow inside. 4The complete code for the hollow alphabet diamond pattern is given below. 5Output: 4ConclusionAfter looking at 30 pattern program in python you have learned the basics of creating patterns. Now you can create your own patterns and make them look beautiful. Try the alphabet pattern program discussed in the next article. |