Skip to content
This repository has been archived by the owner on Dec 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #456 from Vaibhavpan02/main
Browse files Browse the repository at this point in the history
Create Pyramid_pattern.py
  • Loading branch information
Almas-Ali authored Nov 4, 2022
2 parents 489660b + 44eaf7b commit 7679b0e
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
36 changes: 36 additions & 0 deletions LeftTriangle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import java.io.*;

// java program for left triangle
public class GFG {
// Function to demonstrate printing pattern
public static void StarleftTriangle(int k)
{
int a, b;

// 1st loop
for (a = 0; a < k; a++) {

// nested 2nd loop
for (b = 2 * (k - a); b >= 0; b--) {
// printing spaces
System.out.print(" ");
}

// nested 3rd loop
for (b = 0; b <= a; b++) {
// printing stars
System.out.print("* ");
}

// end-line
System.out.println();
}
}

// Driver Function
public static void main(String args[])
{
int k = 5;
StarleftTriangle(k);
}
}
19 changes: 19 additions & 0 deletions Pyramid_pattern.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
def pypart(n):

# outer loop to handle number of rows
# n in this case
for i in range(0, n):

# inner loop to handle number of columns
# values changing acc. to outer loop
for j in range(0, i+1):

# printing stars
print("* ",end="")

# ending line after each row
print("\r")

# Driver Code
n = 5
pypart(n)

0 comments on commit 7679b0e

Please sign in to comment.