“pola piramida python” Kode Jawaban

Pola Piramida Nomor dalam Python

# pyramid number pattern
n = 5
for i in range(n):
    for j in range(n - i - 1):
        print(' ', end='')
    for k in range(2 * i + 1):
        print(k + 1, end='')
    print()
Clumsy Caiman

pola piramida dalam python

n = 3
for i in range(1, n+1):
  print(f"{' '*(n-i)}{' *'*i}"[1:])
  
# Output:
#  *
# * *
#* * *
bokaif

pola piramida python

rows = int(input("Enter number of rows: "))

for i in range(rows):
    for j in range(i+1):
        print("* ", end="")
    print("\n")
Yasir Abdul

pola piramida python

# Python 3.x code to demonstrate star pattern
 
# Function to demonstrate printing pattern triangle
def triangle(n):
     
    # number of spaces
    k = n - 1
 
    # outer loop to handle number of rows
    for i in range(0, n):
     
        # inner loop to handle number spaces
        # values changing acc. to requirement
        for j in range(0, k):
            print(end=" ")
     
        # decrementing k after each loop
        k = k - 1
     
        # inner loop to handle number of columns
        # values changing acc. to outer loop
        for j in range(0, i+1):
         
            # printing stars
            print("* ", end="")
     
        # ending line after each row
        print("\r")
 
# Driver Code
n = 5
triangle(n)
Rachel Wu

Jawaban yang mirip dengan “pola piramida python”

Pertanyaan yang mirip dengan “pola piramida python”

Lebih banyak jawaban terkait untuk “pola piramida python” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya