Python Script Challenge

Community Announcement: Python Script Challenge

Calling all students! Here’s a fun Python script challenge for you. Write a Python script to create and print a pyramid-like structure. The expected output should resemble a pyramid. Get creative and test your Python skills!

Expected Output:

                                         *
                                        ***
                                       *****
                                      *******
                                     *********
1 Like

@dkdebarun666
rows = 5
for i in range(rows):
for j in range(rows -i -1):
print(" β€œ,end=” β€œ)
for k in range(i +i +1):
print(”*",end = " ")
print()

1 Like

rows = 5
for i in range(rows):
for j in range(rows -i - 1):
print(’ β€˜, end = β€˜β€™)
for k in range(i +i +1):
print(’*',end = β€˜β€™)
print()

1 Like

@dkdebarun666
rows = 5
k = 1
for i in range(rows,0,-1):
for j in range(1,i+1):
print(’ β€˜,end=’ β€˜)
for i in range(1,2k):
print('
’,end=’ β€˜)
k=k+1
for l in range(1,j+1):
print(’ β€˜,end=’ ')
print()

1 Like
def printPyramid(height):
    for i in range(1, height + 1):
        # Print spaces for left alignment
        print(" " * (height - i), end="")

        # Print asterisks for the current level
        print("*" * (2 * i - 1))

# Specify the height of the pyramid
height = 5

# Call the function to print the pyramid
printPyramid(height)

1 Like

Good job, keep practising.