Professional Documents
Culture Documents
Alok Raj(216301012) 3.2 python assignment
Alok Raj(216301012) 3.2 python assignment
Alok Raj(216301012) 3.2 python assignment
1 - Inverted Triangle
Code:-
rows = int(input("Enter number of rows: "))
for i in range(rows, 0, -1):
for j in range(0, i):
print("* ", end=" ")
print("\n")
output:-
***
**
*
Code:-
N=int(input("Enter number of rows : "))
row=1;
while row<=N:
col=1;
while col<=N:
if(col<=N-row):
print(" ",end="")
else:
print("*",end="")
col=col+1
row=row+1
print(" ")
output:-
*
**
***
Code:-
N=int(input("Enter Number of Rows : "))
row=1;
while row<=N:
spaces =1
while spaces<= N- row:
print(" ",end="")
spaces=spaces+1
num=1
while num<=row:
print(num,end="")
num=num+1;
num=row-1
while num>=1:
print(num,end="")
num=num-1
print()
row=row+1
output:-
1
121
12321
1234321
Practice Problem
Code:-1
output:-
code:-2
N=int(input("Enter No. :"))
row=1
while (row<=N):
output:-
code:-3
N=int(input("Enter No. :"))
row=1
while (row<=N):
output:-
code:-4
output:-