Computer Science, asked by AbhijithPrakash, 11 months ago

Language: Python


Write the code (syntax) for printing the following pattern.

Attachments:

AbhijithPrakash: The 2 images in the attachment are same...
AbhijithPrakash: But If you need spaces in between the asterisks, as shown in the image;
You can use the following commands:

for i in range(0,5):
print('* '*(6-(i+1))+' '*(i*4)+'* '*(6-(i+1)))
for i in range(5,0,-1):
print('* '*(6-(i))+' '*((i*4)-4)+'* '*(6-(i)))
AbhijithPrakash: OR

for i in range(1,6):
for j in range(6,i,-1):
print("*", end=" ")
for k in range(1,i):
print(" ", end=" ")
for l in range(1,i):
print(" ", end=" ")
for m in range(6,i,-1):
print("*", end=" ")
print()
for i in range(6,1,-1):
for j in range(i,7):
print("*", end=" ")
for k in range(2,i):
print(" ", end=" ")
for l in range(2,i):
print(" ", end=" ")
for m in range(7,i,-1):
print("*", end=" ")
print()

Answers

Answered by LuckyYadav2578
15

Programme to print star pattern in Python

for i in range (4, 0, -1):

for j in range (0 ,i*2+1):

 if j== i:

  print ( " "* (4-i)*2, end="")

 else:

  print (end ="*")

print ()

for i in range(1, 5):

for j in range(0, i*2+1):

 if j== i:

  print (" "* (4-i)*2, end="")

 else:

  print (end="*")

print ()

=> See the output in attachment

Attachments:
Answered by Anonymous
0

Hello Mate !!!

Refer to attachment

Attachments:
Similar questions