This repository contains various pattern printing programs written in Python. These functions print different patterns using loops, stars (*), numbers, and characters. Each function is designed to take a numerical input and output a unique pattern to the console. Below is a detailed description of each function and the pattern it generates.
-
Clone the repository:
git clone https://github.com/your-username/pattern-printing.git
-
Navigate to the project directory:
cd pattern-printing -
Ensure you have Python installed. You can check this by running:
python --version
-
Run any of the Python scripts using:
python script_name.py
Each pattern function takes a single integer input (typically representing the number of rows or the size of the pattern) and prints the respective pattern to the console.
To use any function:
- Import the function into your script or run the function directly by passing the desired number of rows or size.
- Example:
pattern7(5)
This function prints a pyramid of stars with centered alignment and spaces on each side. The pyramid grows in size as the input number increases.
Example for num = 5:
*
* * *
* * * * *
* * * * * * *
* * * * * * * * *
Prints an inverted pyramid of stars with spaces on each side. The pattern reduces in size as the rows increase.
Example for num8 = 5:
* * * * * * * * *
* * * * * * *
* * * * *
* * *
*
Combines both the pyramid and inverted pyramid from Patterns 1 and 2 to print a diamond-shaped star pattern.
Example for num = 5:
*
* * *
* * * * *
* * * * * * *
* * * * * * * * *
* * * * * * *
* * * * *
* * *
*
Prints a mirrored half-diamond pattern using stars.
Example for num10 = 5:
*
* *
* * *
* * * *
* * * * *
* * * *
* * *
* *
*
Prints a binary number pattern that alternates between 0 and 1 for each row, starting with a different number on even and odd rows.
Example for num11 = 5:
0
1 0
0 1 0
1 0 1 0
Prints a number pyramid pattern with spaces between the numbers and mirrors the numbers on both sides.
Example for num12 = 5:
1 1
1 2 2 1
1 2 3 3 2 1
1 2 3 4 4 3 2 1
Prints incremental numbers row by row.
Example for num13 = 5:
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
Prints a triangle of increasing characters (A, B, C...) row by row.
Example for num14 = 5:
A
A B
A B C
A B C D
Prints a triangle of decreasing characters starting from A.
Example for num15 = 5:
A B C D
A B C
A B
A
Prints a triangle of increasing characters but starts with ASCII values after 'A'.
Example for num16 = 5:
A
B B
C C C
D D D D
Prints a triangle of increasing alphabet characters, centered with spaces.
Example for num17 = 5:
A
A B
A B C
A B C D
A B C D E
This project is licensed under the MIT License.
Enjoy creating and printing unique patterns! 🎨