Search the Blog

Monday, August 26, 2019

Pyhtan * Pattern Program with Space

As all of us knows that as we used to print the pattern program in C, C++, JAVA,Net, etc. to make comfortable to the new user as we started learning that programming language.

In the same way to make confidence and learn syntax and logic writting style in Python. We can practice as many prgram for this i am showing to all of you more than 20 pattern program code in Python.
You can copy and paste these code and even test at your own system. Users can modify these Codes too.

Python pattern program with space and Star(*) 

Pyhtan * Pattern Program with Space

Program Code-


def python_pattern(n):
    # outer loop will handle number of rows    
    # n in this case    
    for i in range(0, n):
        # inner loop will handle number 
          of columns for space printing        
       for k in range(0, n-i):
            # printing stars            
            print("  ", end="")
        # inner loop will handle number of columns 
        for star printing        
       for j in range(0, i + 1):
            # printing stars
            print("* ", end="")
            # ending line after each row
        print("\r")
    # Driver Code
n = 6python_pattern(n)





Output-


                 * 
              * * 
           * * * 
        * * * * 
     * * * * * 
  * * * * * * 


No comments:

Post a Comment

Translate