Computer Science, asked by Anthaea, 2 months ago

Generate the pattern in python programming

Attachments:

Answers

Answered by ZalimGudiya
4

Answer:

Pattern - 1: Number Pattern

1 rows = int(input("Enter the number of rows: "))

2 # Outer loop will print number of rows.

3 for i in range(rows+1):

4 # Inner loop will print the value of i after each iteration.

5 for j in range(i):

6 print(i, end=" ") # print number.

7 # line after each row to display pattern correctly.

8 print(" ")

Answered by Oreki
33

{\bf Co de}

   \texttt{for row in range(1, 5 + 1): \# Goes from 1 to 5.}\\\texttt{\hspace{1.5em} for column in range(1, row + 1): \# Goes from 1  until the row.}\\\texttt{\hspace{3em} print(end="* ")}\\\texttt{\hspace{1.5em} print()}

{\bf Out put}

   \texttt{*}\\\texttt{* *}\\\texttt{* * *}\\\texttt{* * * *}\\\texttt{* * * * *}

Similar questions