Computer Science, asked by Anonymous, 4 months ago

Print the pattern shown in attachment by using loop method in python.

Attachments:

Answers

Answered by ItzDinu
5

\begin{gathered}{\Huge{\textsf{\textbf{\underline{\underline{\purple{Answer:}}}}}}}\end{gathered}

\implies The Loop Method I Know ;)

Attachments:
Answered by anindyaadhikari13
3

\texttt{\textsf{\large{\underline{Solution}:}}}

The given co‎de is written in Python 3.

n=3

for i in range(n,-n-1,-1):

 for _ in range(1,abs(i)+1):

   print("  ",end="")

 for _ in range(n,abs(i)-1,-1):

   print("*   ",end="")

 print()

Three loops are used here. Outer loop iterates 7 times as there are 7 rows for the pattern. There are two inner loops. First loop prints spaces where necessary and second loop prints stars. A new line is then inserted.

Attachments:
Similar questions