# Inverted Star Sample in Python – Know Program

Inverted star sample in Python | Right here we are going to write inverted star sample packages within the Python language. The star sample is a sample that consists of a collection of stars. The variety of stars is decided by the variety of rows and columns. Some patterns and check circumstances are given, after observing these patterns we are going to write Python packages to show them on the display. To show patterns we should be nested For Loop and Whereas Loop.

Observe:- Outer loop is used for rows and the inside loop is used to show columns (assume Matrix). That’s why the variety of rows is managed by the outer loop however for displaying values in these columns the inside loop is used.

In these packages for a greater understanding objective, we now have used i, j as loop iterator variables (i => row,  j => column).

## Inverted Star Sample Applications in Python utilizing For Loop

### Inverted Star Sample Program 1

Within the beneath sample program, we are going to print the inverted left half pyramid. We are going to print N numbers of stars within the first row, N-1 stars within the second row and proceed doing this in a similar way till we attain row 1 star. The inverted left half pyramid sample is similar because the left half pyramid sample however it’s the other way up.

Pattern Enter/ Output:-

Enter the variety of rows: 4
`* * *`
`* *`
`*`

Enter the variety of rows: 7
`* * * * * *`
`* * * * *`
`* * * *`
`* * *`
`* *`
`*`

``````# Python program to print inverted left half pyramid star sample

def sample(n):
for i in vary(n):
for j in vary(n-i-1):
# printing stars
print("* ",finish="")
print(" ")

# take inputs
n = int(enter('Enter the variety of rows: '))

# calling perform
sample(n)
``````

Quick Strategies

``````# Python program to print inverted left half pyramid star sample

def sample(n):
for i in vary(n):
# printing stars
print("* " * (n-i))

# take inputs
n = int(enter('Enter the variety of rows: '))

# calling perform
sample(n)
``````

### Inverted Star Sample Program 2

We are going to print the inverted proper half pyramid. The inverted proper half pyramid sample is similar as the appropriate half pyramid sample however it’s the other way up.

Pattern Enter/ Output:-

``````Enter the variety of rows: 6

* * * * *
* * * *
* * *
* *
*
``````
``````# Python program to print inverted proper half pyramid star sample

def sample(n):
for i in vary(n-1):
for j in vary(i+1):
# printing areas
print(" ",finish=" ")

for okay in vary(n-i-1):
# printing stars
print("* ",finish="")
print()

# take inputs
n = int(enter('Enter the variety of rows: '))

# calling perform
sample(n)
``````

### Inverted Star Sample Program 3

The inverted triangle or pyramid sample is similar because the triangle sample however it’s the other way up. We are going to run 3 nested loops, out of which the primary for loop is for looping of the column and the opposite 2 for loops (the sub loops) for looping of the row.

Pattern Enter/ Output:-

``````Enter the variety of rows: 8

* * * * * * * * * * * * * * *
* * * * * * * * * * * * *
* * * * * * * * * * *
* * * * * * * * *
* * * * * * *
* * * * *
* * *
* ``````
``````# Python program to print inverted pyramid star sample

def sample(n):
for i in vary(n, 0, -1):
for j in vary(n-i):
# printing areas
print(" ",finish=" ")

for j in vary(2*i-1):
# printing stars
print("* ",finish="")
print()

# take inputs
n = int(enter('Enter the variety of rows: '))

# calling perform
sample(n)
``````

### Inverted Star Sample Program 4

On this sample, we are going to print the appropriate pascal triangle. Print two half pyramids, one left half pyramid, and the second inverted left half pyramid.

Pattern Enter/ Output:-

Enter the variety of rows: 3
`*`
`* *`
`* * *`
`* *`
`*`

``````# Python program to print proper pascal triangle star sample

def sample(n):
# print higher triangle
for i in vary(n):
for j in vary(i+1):
# printing stars
print("* ",finish="")
print("r")

# print decrease triangle
for i in vary(n):
for j in vary(n-i-1):
# printing stars
print("* ",finish="")
print("r")

# take inputs
n = int(enter('Enter the variety of rows: '))

# calling perform
sample(n)
``````

Easy Strategies

``````# Python program to print proper pascal triangle star sample

def sample(n):
for i in vary(n):
print('* ' * (i + 1))
for i in vary(n):
print('* ' * (n - i - 1))

# take inputs
n = int(enter('Enter the variety of rows: '))

# calling perform
sample(n)
``````

### Inverted Star Sample Program 5

On this sample, we are going to print the left pascal triangle. Print two half pyramids, one proper half pyramid, and the second inverted proper half pyramid.

Pattern Enter/ Output:-

``````Enter the variety of rows: 6

*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * *
* * * *
* * *
* *
*
``````
``````# Python program to print left pascal triangle star sample

def sample(n):
# print higher triangle
for i in vary(n):
for j in vary(n-i-1):
# printing areas
print(" ", finish=" ")

for j in vary(i+1):
# printing stars
print("* ",finish="")
print()

# print decrease triangle
for i in vary(n-1):
for j in vary(i+1):
# printing areas
print(" ",finish=" ")

for j in vary(n-i-1):
# printing stars
print("* ",finish="")
print()

# take inputs
n = int(enter('Enter the variety of rows: '))

# calling perform
sample(n)
``````

### Inverted Star Sample Program 6

On this program, we are going to print a diamond star sample. Print two triangles, one triangle, and the second inverted triangle.

Pattern Enter/ Output:-

``````Enter the variety of rows: 8

*
***
*****
*******
*********
***********
*************
***************
*************
***********
*********
*******
*****
***
*
``````
``````# Python program to print diamond star sample

def sample(n):
# print higher pyramid
for i in vary(n):
for j in vary(n-i-1):
print(" ", finish="")
for j in vary(2*i+1):
# printing stars
print("*", finish="")
print()

# print inverted pyramid
for i in vary(n-1):
for j in vary(i+1):
print(" ", finish="")
for j in vary(2*(n-i-1)-1):
# printing stars
print("*", finish="")
print()

# take inputs
n = int(enter('Enter the variety of rows: '))

# calling perform
sample(n)``````

### Inverted Star Sample Program 7

On this program, we are going to print an hourglass star sample. Print two triangles, one inverted triangle, and the second triangle.

Pattern Enter/ Output:-

``````Enter the variety of rows: 5

* * * * * * * * *
* * * * * * *
* * * * *
* * *
*
* * *
* * * * *
* * * * * * *
* * * * * * * * *
``````
``````# Python program to print hourglass star sample

def sample(n):
# print inverted pyramid
for i in vary(n-1):
for j in vary(i):
print(" ", finish=" ")
for j in vary(2*(n-i)-1):
# printing stars
print("*", finish=" ")
print()

# print higher pyramid
for i in vary(n):
for j in vary(n-i-1):
print(" ", finish=" ")
for j in vary(2*i+1):
# printing stars
print("*", finish=" ")
print()

# take inputs
n = int(enter('Enter the variety of rows: '))

# calling perform
sample(n)
``````

## Inverted Star Sample in Python utilizing Whereas Loop

Within the earlier packages, we now have used the For Loop to print inverted star patterns however within the beneath packages, we are going to use the Whereas Loop.

### Inverted Star Sample Program 8

Pattern Enter/ Output:-

Enter the variety of rows: 5
`* * * * *`
`* * * *`
`* * *`
`* *`
`*`

``````# Python program to print inverted left half pyramid star sample

def sample(n):
i = 1
whereas i <= n :
j = n
whereas j >= i:
# printing stars
print("*", finish=" ")
j = j - 1
print()
i = i + 1

# take inputs
n = int(enter('Enter the variety of rows: '))

# calling perform
sample(n)
``````

Quick Strategies

``````# Python program to print inverted left half pyramid star sample

def sample(n):
i = n
whereas i>=1:
# printing stars
print("* " * i)
i-=1

# take inputs
n = int(enter('Enter the variety of rows: '))

# calling perform
sample(n)
``````

### Inverted Star Sample Program 9

Pattern Enter/ Output:-

``````Enter the variety of rows: 6

* * * * * *
* * * * *
* * * *
* * *
* *
* ``````
``````# Python program to print inverted proper half pyramid star sample

def sample(n):
i = n
whereas i>=1:
# printing stars
print(" "*(n-i) + "*" * i)
i-=1

# take inputs
n = int(enter('Enter the variety of rows: '))

# calling perform
sample(n)
``````

### Inverted Star Sample Program 10

Pattern Enter/ Output:-

``````Enter the variety of rows: 4

* * * *
* * *
* *
*
``````
``````# Python program to print inverted triangle star sample

def sample(n):
i = n
whereas i>=1:
# printing stars
print(" "*(n-i) + "* " * i)
i-=1

# take inputs
n = int(enter('Enter the variety of rows: '))

# calling perform
sample(n)
``````

### Inverted Star Sample Program 11

Pattern Enter/ Output:-

Enter the variety of rows: 3
`*`
`* *`
`* * *`
`* *`
`*`

``````# Python program to print proper pascal triangle star sample

def sample(n):
# print higher triangle
i = 1
whereas i<n:
# printing stars
print("* " * i)
i+=1

# print decrease triangle
i = n
whereas i>=1:
# printing stars
print("* " * i)
i-=1

# take inputs
n = int(enter('Enter the variety of rows: '))

# calling perform
sample(n)
``````

### Inverted Star Sample Program 12

Pattern Enter/ Output:-

``````Enter the variety of rows: 7

*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * *
* * * * *
* * * *
* * *
* *
* ``````
``````# Python program to print left pascal triangle star sample

def sample(n):
# print higher triangle
i = 1
whereas i<n:
# printing stars
print(" "*(n-i) + "*" * i)
i+=1

# print decrease triangle
i = n
whereas i>=1:
# printing stars
print(" "*(n-i) + "*" * i)
i-=1

# take inputs
n = int(enter('Enter the variety of rows: '))

# calling perform
sample(n)
``````

### Inverted Star Sample Program 13

Pattern Enter/ Output:-

``````Enter the variety of rows: 5

*
* *
* * *
* * * *
* * * * *
* * * *
* * *
* *
*
``````
``````# Python program to print diamond star sample

def sample(n):
# print higher triangle
i = 1
whereas i<n:
# printing stars
print(" "*(n-i) + "* " * i)
i+=1

# print decrease triangle
i = n
whereas i>=1:
# printing stars
print(" "*(n-i) + "* " * i)
i-=1

# take inputs
n = int(enter('Enter the variety of rows: '))

# calling perform
sample(n)
``````

### Inverted Star Sample Program 14

Pattern Enter/ Output:-

``````Enter the variety of rows: 7

* * * * * * *
* * * * * *
* * * * *
* * * *
* * *
* *
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *``````
``````# Python program to print hourglass star sample

def sample(n):
# print higher triangle
i = n
whereas i>1:
# printing stars
print(" "*(n-i) + "* " * i)
i-=1

# print decrease triangle
i = 1
whereas i<=n:
# printing stars
print(" "*(n-i) + "* " * i)
i+=1

# take inputs
n = int(enter('Enter the variety of rows: '))

# calling perform
sample(n)
``````

## Inverted Star Sample in Python

Within the beneath sample packages, we are going to print the hole inverted star sample. The hole star sample packages are a bit harder than easy star sample packages as a result of right here you’ll have to cope with areas.

### Inverted Star Sample Program 15

Pattern Enter/ Output:-

``````Enter the variety of rows: 6

* * * * * *
*       *
*     *
*   *
* *
*
``````
``````# Python program to print inverted left half pyramid star sample

def sample(n):
for i in vary(n, 0, -1):
for j in vary(i, 0, -1):
if i == 1 or i == n or j == 1 or j == i:
# printing stars
print("*", finish=" ")
else:
print(" ", finish=" ")
print()

# take inputs
n = int(enter('Enter the variety of rows: '))

# calling perform
sample(n)
``````

### Inverted Star Sample Program 16

Pattern Enter/ Output:-

``````Enter the variety of rows: 6

* * * * * * * * * * *
*               *
*           *
*       *
*   *
*
``````
``````# Python program to print inverted pyramid star sample

def sample(n):
for i in vary(1, n+1):
for j in vary(0, i):
print(" ", finish=" ")

for j in vary(1, (n*2 - (2*i-1)) + 1):
if i == 1 or j == 1 or j ==(n*2 -(2*i-1)):
# printing stars
print("*", finish=" ")
else:
print(" ", finish=" ")
print()

# take inputs
n = int(enter('Enter the variety of rows: '))

# calling perform
sample(n)
``````

### Inverted Star Sample Program 17

Pattern Enter/ Output:-

``````Enter the variety of rows: 6

*
* *
*   *
*     *
*       *
*         *
*       *
*     *
*   *
* *
*``````
``````# Python program to print hole diamond star sample

def sample(n):
# print higher hole pyramid
for i in vary(n):
for j in vary(n-i-1):
print(" ", finish=" ")
for j in vary(2*i+1):
if j == 0 or j == 2*i:
# printing stars
print("*", finish=" ")
else:
print(" ", finish=" ")
print()

# print inverted hole pyramid
for i in vary(n-1):
for j in vary(i+1):
print(" ", finish=" ")
for j in vary(2*(n-i-1)-1):
if j == 0 or j == 2*(n-i-1)-2:
# printing stars
print("*", finish=" ")
else:
print(" ", finish=" ")
print()

# take inputs
n = int(enter('Enter the variety of rows: '))

# calling perform
sample(n)
``````

### Inverted Star Sample Program 18

Pattern Enter/ Output:-

``````Enter the variety of rows: 5

* * * * * * * * *
*           *
*       *
*   *
*
*   *
*       *
*           *
* * * * * * * * *
``````
``````# Python program to print hole hourglass star sample

def sample(n):
# print higher hole hourglass
for i in vary(n, 0, -1):
for j in vary(n-i):
print(" ", finish=" ")
for j in vary(1, 2*i):
if i==1 or i==n or j==1 or j==2*i-1:
# printing stars
print("*", finish=" ")
else:
print(" ", finish=" ")
print()

# print decrease hole hourglass
for i in vary(2, n+1):
for j in vary(n-i):
print(" ", finish=" ")
for j in vary(1, 2*i):
if i==n or j==1 or j==2*i-1:
# printing stars
print("*", finish=" ")
else:
print(" ", finish=" ")
print()

# take inputs
n = int(enter('Enter the variety of rows: '))

# calling perform
sample(n)``````

Additionally See:- Pattern Programs in C