From e1a6ba3e24b1e1aea1b40fdf6ba28c0cadb79d32 Mon Sep 17 00:00:00 2001 From: Albert Sharma <74003971+Albert-Sharma@users.noreply.github.com> Date: Tue, 12 Oct 2021 13:50:14 +0530 Subject: [PATCH] basicstarpattern.py Here I have mentioned 2 methods to proceed with this kind of problem. --- basicstarpatterns.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 basicstarpatterns.py diff --git a/basicstarpatterns.py b/basicstarpatterns.py new file mode 100644 index 00000000..0fc25495 --- /dev/null +++ b/basicstarpatterns.py @@ -0,0 +1,35 @@ +#--------------------QUESTION--------------# + +# +## +### +#### +##### + +# METHOD 1 +print("Method1 \n") +def fun1(n): #Function declaration + + #outer loop for number of rows + for i in range(0,n): + + #inner loop for number of columns + for j in range(0, i+1): + print("*", end="") + + #Ending the line after each row + print("\r") + +n =5 +fun1(5) + +# METHOD 2 +print("\nMethod2 \n") + +def fun2(m): + list = [] + for i in range(1 , m+1): + list.append("*"*i) + print("\n".join(list)) +m = 5 +fun2(m)