From 1718a811a8b8f5a9a9e5e8eb1ba90e2d766f0000 Mon Sep 17 00:00:00 2001 From: Alimaja <92705063+Alimaja@users.noreply.github.com> Date: Tue, 19 Oct 2021 10:17:28 +0700 Subject: [PATCH] Create pyramid.py --- Patterns/pyramid.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Patterns/pyramid.py diff --git a/Patterns/pyramid.py b/Patterns/pyramid.py new file mode 100644 index 00000000..1d033901 --- /dev/null +++ b/Patterns/pyramid.py @@ -0,0 +1,22 @@ +# Python 3.x code to demonstrate star pattern + +# Function to demonstrate printing pattern +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)