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/ 3
Lab Programs Nov 25Mon
# Programs to construct patterns of stars (*), using a nested for loop.
1. program to print 5 rows of stars in right angle form * ** *** **** ***** rows=5 for i in range(1,rows+1): for j in range(1,i+1): print("*",end='') print() 2. program to print 4 rows of stars in right angle form rows=5 for i in range(1,rows+1): for j in range(1,i): print("*",end='') print()
3. program to print inverted 5 rows of stars in inverted right angle form
rows=5 for i in range(rows,0,-1): for j in range(1,i+1): print("*",end='') print() 4. program to print inverted 4 rows of stars in inverted right angle form rows=5 for i in range(rows,0,-1): for j in range(1,i): print("*",end='') print()
5. program to print 5 rows of 5 stars(square pattern)
***** ***** ***** ***** ***** rows=5 for i in range(1,rows+1): for j in range(1,rows+1): print("*",end='') print()
6 .b=int(input("Enter the level:"))
for i in range(b): for j in range(b): print("*",end='') print() 7. b=int(input("Enter the level:")) for i in range(1,b+1): for j in range(1,i+1): print("*",end='') print()
8. b=int(input("Enter the level:"))
for i in range(b,0,-1): for j in range(1,i+1): print("*",end='') print()