0

29views

Write a Python Program to Create Pyramid No Pattern (Value will be Column no +1)

**1 Answer**

0

29views

Write a Python Program to Create Pyramid No Pattern (Value will be Column no +1)

0

0views

written 9 days ago by |

**Explanation:-**

**Step 1:-** Take input for no of rows

**Step 2:-** Start 1st for loop to iterate n no of times (n rows)

**Step 3:-** Take 2nd for loop to iterate i items in a row

1st iteration (i=1) 2nd for loop will iterate 1 time

**Output:-**

1

2nd iteration (i=2) 2nd for loop will iterate 2 times

**Output:-**

1

1 2

Similarly

nth iteration (i=n) 2nd for loop will iterate n times

**Step 4:-** Increment the value of i from 1 to n

**Step 5:-** Stop

**Hint:-** The value to be printed is +1 the column value

for column 0 the value to be printed would be 1 so print(j+1)

for column n the value to be printed would be n+1 so print(n+1)

**Method 1:-**

```
n=int(input("No of Rows in the pattern: "))
for i in range(n+1):
for j in range(i):
print(j+1,end=" ")
print()
```

**Method 2:-**

```
n=int(input("No of Rows in the pattern: "))
for i in range(1,n+1):
for j in range(1,i+1):
print(j,end=' ')
print()
```

**Method 3:-**

```
n=int(input("No of Rows in the pattern: "))
for i in range(1,n+1):
for i in range(1,i+1):
print(i,end=" ")
print()
```

**Output:-**

ADD COMMENT
EDIT

Please log in to add an answer.