0% found this document useful (0 votes)
9 views

ALOK RANJAN JHA Lab Assignment3

I am

Uploaded by

216301012
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

ALOK RANJAN JHA Lab Assignment3

I am

Uploaded by

216301012
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Square Patterns

Code :- 1.1

N=int(input("Enter No."))
row=1
while (row<=N):
col=1
while(col<=N):
print("*",end=" ")
col=col+1
row=row+1
print( )

output:-
Code :- 1.2

N=int(input("Enter No."))
row=1
while (row<=N):
col=1
while(col<=N):
print(row,end=" ")
col=col+1
row=row+1
print( )

output:-
Code :- 1.3

N=int(input("Enter No."))
row=1
while (row<=N):
col=1
while(col<=N):
print(col,end=" ")
col=col+1
row=row+1
print( )

output:-
Code :- 1.4

N=int(input("Enter No."))
row=1
while (row<=N):
col=1
while(col<=N):
print(N+1-col,end=" ")
col=col+1
row=row+1
print( )

output:-
Code :- 1.5
N=int(input("Enter No."))
row=1
while (row<=N):
col=1
while(col<=N):
print(row+col-1,end=" ")
col=col+1
row=row+1
print( )

output:-
Triangular Patterns
Code :- 1.6
N=int(input("Enter No."))
row=1
while (row<=N):
col=1
while(col<=row):
print(row,end=" ")
col=col+1
row=row+1
print( )
output:-

Code :- 1.7
N=int(input("Enter No."))
row=1
while (row<=N):
col=1
while(col<=row):
print(col,end=" ")
col=col+1
row=row+1
print( )
output:-

Code :- 1.8
N=int(input("Enter No."))
row=1
temp=1
while (row<=N):
col=1
while(col<=row):
print(temp,end=" ")
temp=temp+1
col=col+1
row=row+1
print( )

output:-

Character Patterns
Code :- 1.9
N=int(input("Enter No."))
row=1
temp=1
while (row<=N):
col=1
while(col<=N):
print(chr(64+col),end=" ")
col=col+1
row=row+1
print( )

output:-

Code :- 1.10
N=int(input("Enter No."))
row=1
while (row<=N):
col=1
while(col<=N):
print(chr(64+row+col-1),end=" ")
col=col+1
row=row+1
print( )

output:-

Practice Problems
Problems:-1
N=int(input("Enter No."))
row=1
while (row<=N):
col=1
while(col<=row):
print(chr(64+col),end=" ")
col=col+1
row=row+1
print( )

output:-

Problems:-2
N=int(input("Enter No."))
row=1
while (row<=N):
col1=1
col2=1
col3=N+1-row
while(col1<=N+1-row):
print(col1,end=" ")
col1=col1+1
while (col2<=2*row-2):
print("*",end=" ")
col2=col2+1
while (col3>=1) :
print(col3,end=" ")
col3=col3-1
row=row+1
print( )
output:-

Problems:-3
N=int(input("Enter No."))
row=1
while (row<=N):
col1=1
while(col1<=N+1-row):
print(chr(64+col1),end=" ")
col1=col1+1
row=row+1
print( )
output:-
Problems:-4
N=int(input("Enter No."))
row=1
temp=N
while (row<=N):
col=1
while(col<=N):
if(temp!=N+1):
print(temp,end=" ")
temp=temp+1
else:
print(temp,end=" ")
col=col+1
row=row+1
temp=N+1-row
print( )
output:-

Problems:-5
n = int(input())
i=1

while i <= n:
j=1
while j <= i:
if i == 1:
print(1,end ='')

elif j == 1 or j == i:
print(i-1,end ='')

else:
print(0,end='')

j=j+1
print()
i=i+1
output:-
Problems:-6
N=int(input("Enter No."))
row=1
while (row<=N):
col=1
while(col<=row):
print(chr(64+row),end=" ")
col=col+1
row=row+1
print( )
output:-

You might also like