-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #270 from SanskarSh/Sanskar-266
Adding code for pattern
- Loading branch information
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
Patterns/Pyramid_Patterns/Code/Pyramid_Pattern_3/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Pyramid Pattern 3 | ||
|
||
**Pattern Image:** | ||
|
||
![image](../../img/pyramidpattern3.PNG) | ||
|
||
**Contributor:** [Sanskar Shrivastava](https://github.com/SanskarSh) | ||
|
||
:star2: Star it :fork_and_knife:Fork it :handshake: Contribute to it! | ||
|
||
Discord server - http://pragmaticprogrammer.in/discord | ||
|
||
Happy Coding :purple_heart: |
16 changes: 16 additions & 0 deletions
16
Patterns/Pyramid_Patterns/Code/Pyramid_Pattern_3/pyramid_pattern_3.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Set the number of rows for the pattern | ||
n = 5 | ||
|
||
# Loop through rows from 1 to 'n'. | ||
for i in range(1, n + 1): | ||
|
||
# Loop to print spaces before the numbers in each row. | ||
for k in range(1, n - i + 1): | ||
print(" ", end=" ") | ||
|
||
# Loop to print numbers in ascending order in each row. | ||
for j in range(1, i + 1): | ||
print(j, end=" ") | ||
|
||
# Move to the next line to start a new row. | ||
print() |