Python Program to Print Inverted V Star Pattern

Write a Python program to print inverted V star pattern or half diamond inside a square star pattern using for loop.

rows = int(input("Enter Inverted V Star Pattern Rows = "))

print("====The Inverted V Star Pattern====")

for i in range(rows, 0, -1):
    for j in range(1, i + 1):
        print('*', end = '')
    for k in range(1, 2 * (rows - i) + 1):
        print(end = ' ')
    for l in range(1, i + 1):
        print('*', end = '')
    print()
Python Program to Print Inverted V Star Pattern

This Python program displays the inverted V star pattern of stars using a while loop.

rows = int(input("Enter Inverted V Star Pattern Rows = "))

print("====The Inverted V Star Pattern====")
i = rows

while(i >= 1):
    j = 1
    while(j <= i):
        print('*', end = '')
        j = j + 1
    k = 1
    while(k <= 2 * (rows - i)):
        print(end = ' ')
        k = k + 1
    l = 1
    while(l <= i):
        print('*', end = '')
        l = l + 1
    print()
    i = i - 1
Enter Inverted V Star Pattern Rows = 9
====The Inverted V Star Pattern====
******************
********  ********
*******    *******
******      ******
*****        *****
****          ****
***            ***
**              **
*                *

In this Python pattern example, we created a function that allows entering any character and prints the inverted V of a given character.

def InvertedVStar(i, ch):
    for j in range(1, i + 1):
        print('%c' %ch, end = '')

rows = int(input("Enter Inverted V Star Pattern Rows = "))

ch = input("Symbol to use in V Pattern = " )

print("====The Inverted V Star Pattern====")

for i in range(rows, 0, -1):
    InvertedVStar(i, ch)
    for k in range(1, 2 * (rows - i) + 1):
        print(end = ' ')
    InvertedVStar(i, ch)
    print()
Enter Inverted V Star Pattern Rows = 14
Symbol to use in V Pattern = #
====The Inverted V Star Pattern====
############################
#############  #############
############    ############
###########      ###########
##########        ##########
#########          #########
########            ########
#######              #######
######                ######
#####                  #####
####                    ####
###                      ###
##                        ##
#                          #