Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

asterisk triangle print

# 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("
")
 
# Driver Code
n = 5
triangle(n)
Comment

PREVIOUS NEXT
Code Example
Python :: fill missing values with dict 
Python :: how to un register DefaultAdminSite in django 
Python :: Find Factors of a Number using While Loop with validation 
Python :: Command to install Voluptuous Python Library 
Python :: Flatten List in Python Using NumPy Ravel 
Python :: Handling errors while using os.makedirs() method 
Python :: matplotlib legend from scratch 
Python :: how to return and use a single object in custom template filters django 
Python :: maximum of a list in python recursively 
Python :: scikit learn lazy predict 
Python :: unique lits on python 
Python :: Python slides 
Python :: how to plot a single centroid 
Python :: python jupyter show cell execution progress bar 
Python :: python split respect quotes 
Python :: Algorithm of Broadcasting with NumPy Arrays 
Python :: block size explained in python hashlib module 
Python :: find duplicate row in python sqlite database 
Python :: Python NumPy asarray_chkfinite Function Example List to an array 
Python :: get text from heatmap 
Python :: how to add to an exsiting value of an index in a list 
Python :: Python __ge__ magic method 
Python :: selenium rotate user agent 
Python :: NumPy packbits Syntax 
Python :: change admin password djano 
Python :: penggunaan fromkeys di python 
Python :: list python !g 
Python :: gremlin python import 
Python :: what does scalar.fit do 
Python :: python list len 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =