Search the Blog

Wednesday, September 4, 2019

Python pattern from from incresing and descresing sequnce of numbers

This post will explain the logic, code and Syntax for pattern program in Python Programming. In this post you will understand how to right the code of a pattern which have the sequence in  descreasing and incresinng sequence.


Python pattern from from incresing and descresing sequnce of numbers


 Pattern Code-
def python_pattern(n):
    for i in range(0, n):
        if n/2 >= i:
            for j in range(1, i+1):
                print(j, end=" ")
            print("\r")
        else:
            for j in range(1, n - i + 1):
                print(j, end=" ")
            print("\r")
n=10python_pattern(n)

Output:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1

Youtube Video of Complete Program


See Also-Python patthern program of all types


No comments:

Post a Comment

Translate