Python icon indicating copy to clipboard operation
Python copied to clipboard

Print a butterfly pattern using python.

Open ElusiveParadox opened this issue 1 year ago • 6 comments

Feature description

You need to take a user input n. and print a butterfly pattern using the input received from the user as side length.

star

You need to print the above shown pattern from the image.

ElusiveParadox avatar Oct 19 '24 04:10 ElusiveParadox

Assign me this and use label hacktoberfest.

ElusiveParadox avatar Oct 19 '24 04:10 ElusiveParadox

is this issue solved? if not then assign it to me, I would like work on it.

Dream-World-Coder avatar Oct 25 '24 11:10 Dream-World-Coder

Hey, I have optimized the code and reduced the number of lines of code. Can you assign it to me?

AnaghDeshpande avatar Oct 25 '24 19:10 AnaghDeshpande

Hi please assign this issue to me, if it's not closed

HeheAnanya avatar Oct 28 '24 11:10 HeheAnanya

Feature description

You need to take a user input n. and print a butterfly pattern using the input received from the user as side length.

star

You need to print the above shown pattern from the image.

Mrudul1234 avatar Nov 08 '24 16:11 Mrudul1234

Size of the butterfly pattern

size = 5

Upper part of the butterfly

for i in range(1, size + 1): for j in range(1, i + 1): print("", end="") for k in range(1, (2 * (size - i)) + 1): print(" ", end="") for l in range(1, i + 1): print("", end="") print()

Lower part of the butterfly

for i in range(size - 1, 0, -1): for j in range(1, i + 1): print("", end="") for k in range(1, (2 * (size - i)) + 1): print(" ", end="") for l in range(1, i + 1): print("", end="") print()

27371123 avatar Dec 03 '24 03:12 27371123

def butterfly_pattern(n): # Upper part of the butterfly for i in range(1, n + 1): # Print stars on the left side print("" * i, end="") # Print spaces in the middle print(" " * (2 * (n - i)), end="") # Print stars on the right side print("" * i)

# Lower part of the butterfly
for i in range(n, 0, -1):
    # Print stars on the left side
    print("*" * i, end="")
    # Print spaces in the middle
    print(" " * (2 * (n - i)), end="")
    # Print stars on the right side
    print("*" * i)

Change the value of n for a larger or smaller pattern

n = 5 butterfly_pattern(n)

niralinayak avatar Dec 19 '24 15:12 niralinayak