
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Python Program to Print an Inverted Star Pattern
When it is required to print an inverted star pattern in Python, the 'for' loop can be used. This helps iterate over a range of numbers, and print the required character in the required frequency, and the count can be decremented after every iteration.
Below is a demonstration for the same −
Example
N=6 print("The value of 'N' has been initialized to "+str(N)) print("The inverted stars are being displayed") for i in range (N, 0, -1): print((N-i) * ' ' + i * '*')
Output
The value of 'N' has been initialized to 6 The inverted stars are being displayed ****** ***** **** *** ** *
Explanation
- The value of 'N' is initialized and displayed on the console.
- The 'for' loop is iterated over 'N' numbers.
- The required character is printed on the screen.
- Its value is decremented in the next step.
- This is displayed on the console.
- Related Articles
- Golang Program to Print an Inverted Star Pattern
- Java Program to Print Inverted Star Pattern
- Haskell Program to Print Inverted Star Pattern
- Swift Program to Print Inverted Star Pattern
- Swift Program to Print Alphabetic Inverted Pattern
- Swift Program to Print Inverted Binary Pattern
- Swift Program to Print Inverted Numeric Pattern
- Program to print Hut Star pattern
- Java Program to Print Pyramid Star Pattern
- Java Program to Print Diamond Star Pattern
- Java Program to Print Square Star Pattern
- Java Program to Print 8 Star Pattern
- Java Program to Print X Star Pattern
- Haskell Program to Print Diamond Star Pattern
- C++ Program to Print X Star Pattern

Advertisements