03 - PATTERN PROGRAMS IN PYTHON PROGRAMMING

preview_player
Показать описание
PATTERN PROGRAMS IN PYTHON PROGRAMMING

PATTERN - 1
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5

PATTERN - 2
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
Рекомендации по теме
Комментарии
Автор

Wonderful explanation sir. A big thanks🙏

mallikarjuna
Автор

1st method using for loop
print("enter no of rows of 1st pattern ")
rows=int(input())
a=(rows+1)
print("1st pattern is ")
for j in range(1, a):
for k in range(1, j+1):
print(k, end=' ')
print()
print("enter no of rows for 2nd pattern ")
rows=int(input())
print("2nd pattern is ")
b=rows+1
for g in range(1, b):
for j in range(1, b):
print(j, end=' ')
b-=1
print()

tuhinsaha
Автор

Sir just the series it will help lot of students

saikumaryuva
Автор

2nd way using while loop and function
#function for 1st pattern
def func1(rows):
j=1
while j<=rows:
k=1
while k<=j:
print(k, end=' ')
k+=1
print()
j+=1
#function for 2nd pattern
def func2(rows):
while rows>=1:
k=1
while k<=rows:
print(k, end=' ')
k+=1
print()
rows-=1

print ("enter number of rows")
rows=int(input ())
print("pattern according to number is ")
func1(rows)
print("enter no of rows for 2nd one")
rows=int(input ())
print('pattern is ')
func2(rows)

tuhinsaha
Автор

Sir, Code for prime numbers below 100 in python

bhargavbotsa