Python Program to Print (Generate) Flag of Nepal

This python program generates flag of Nepal made up of stars up to n lines.

Note: Here row number indicates number of row in each section in pattern. If we give input row number 7 then total row will be 21 :)

Python Source Code: Flag of Nepal


# Python Program to Generate Flag of Nepal

# Generating Triangle Shape
def triangleShape(n):
    for i in range(n):
        for k in range(i+1):
            print('*',end=' ')
        print()

# Generating Pole Shape
def poleShape(n):
    for i in range(n):
        print('*')

# Input and Function Call
row = int(input('Enter number of rows: '))
triangleShape(row)
triangleShape(row)
poleShape(row)

In this program print() only is used to bring control to new lines.

Output

Enter number of rows: 7

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