PATTERNS
1.
***** ***** ***** ***** *****
2.
* ** *** ****3.***** **** *** ** *4.* * * * * * * * * * * * * * *5.0 0 1 0 1 2 0 1 2 36.1 2 2 3 3 3 4 4 4 47.0 1 2 3 4 5 6 7 8 98.A B C D E F G H I J9.A B B C C C D D D D10.* * * * * * * * * * * * * * *11.* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *12.* ** *** **** ***** **** *** ** *----------------------------------------------------------------------------------#Pattern - 1i= int(input("enter a number ")) for y in range(i): #outer loop tell us about the number of row for x in range(i):#inner loop tell us about the number of colum print("*" , end ="") print()
Output:enter a number 5***** ***** ***** ***** *****# Outer loop rows mai element(*) jodne ke liye hota hai.# Inner loop colum mai element(*) jodne ke liye hota hai.# end="" ka use end mai element jodne ke liye hota hai aur yaha hmne end ka use har * ke baad space dene ke liye kiya hai.#print() ka use next line mai aane ke liye hai.-------------------------------------------------------------------------------------#Pattern - 2i = int(input("enter a number ")) for y in range(i):#outer loop tell us about number of rows for x in range(y):#inner loop tell us about number of coloum print("*" ,end ="") print()
Output:* ** *** ****----------------------------------------------------------------------------------#Pattern - 3i=int(input("enter a number ")) for x in range(i): for y in range(i-x): print("*" , end = "") print("")
Output:
enter a number 5 ***** **** *** ** *----------------------------------------------------------------------------------#Pattern - 4n = int(input("enter a number")) for x in range(n): for y in range(n-x): print(end = " ") for t in range(x+1): print("*" , end = " ") print()
Output:
enter a number 5 * * * * * * * * * * * * * * *--------------------------------------------------------------------------------------#Pattern - 5n = int(input("enter a number")) for x in range(n): for y in range(x): print(y,end =" ") print()
Output:
enter a number 5 0 0 1 0 1 2 0 1 2 3--------------------------------------------------------------------------------------#Pattern - 6n = int(input("enter a number")) for x in range(n): for y in range(x): print(x,end =" ") print()
Output:enter a number 5 1 2 2 3 3 3 4 4 4 4-------------------------------------------------------------------------------#Pattern- 7n = int(input("enter a number")) k=0 for x in range(n): for y in range(x): print(k,end =" ") k=k+1 print()
Output:
enter a number 5 0 1 2 3 4 5 6 7 8 9---------------------------------------------------------------------------------#Pattern - 7n = int(input("enter a number ")) k=65 for x in range(n): for y in range(x): m = chr(k) print(m,end =" ") k=k+1 print()
Output:
enter a number 5 A B C D E F G H I J# The ASCII value of 65 is A-----------------------------------------------------------------------------#Pattern - 8n = int(input("enter a number ")) k=64 for x in range(n): for y in range(x): m = chr(k) print(m,end =" ") k=k+1 print()
Output:
enter a number 5 A B B C C C D D D D--------------------------------------------------------------------------------#Pattern - 9n = int(input("enter a number ")) for x in range(n): for y in range(x): print(end = " ") for z in range(n-x): print("*", end = " ") print()
Output:
enter a number 5* * * * * * * * * * * * * * *--------------------------------------------------------------------------# Pattern - 10n = int(input("enter a number")) u = n for x in range(n): for y in range(n-x): print(end = " ") for t in range(x+1): print("*" , end = " ") print() for a in range(u): for b in range(a): print(end = " ") for z in range(u-a): print("*", end = " ") print()
Output:
enter a number 5 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *#kaju katli 😉-------------------------------------------------------------------------------#Pattern - 11i = int(input("enter a number ")) j=i for y in range(i):#outer loop tell us about number of rows for x in range(y):#inner loop tell us about number of coloum print("*" ,end ="") print() for x in range(j): for y in range(j-x): print("*" , end = "") print("")
Output:enter a number 5 * ** *** **** ***** **** *** ** *---------------------------------------------------------------------------------Doubt ?Feel free to ask in comment section.
Comments
Post a Comment