Inverted Number Pattern in Python

Python program to print inverted right-angled triangle using number. In the Python programming language, there is a down facing number pattern. In the output, this program will print the number inverted. The performance of this program will be printed backwards.

lines = 3
b = 0
for i in range(lines, 0, -1):
b += 1
for j in range(1, i + 1):
print(b, end=' ')
print('\r')

 

Output:

2 2 2 2 2 2 2 2 2

3 3 3 3 3 3 3 3

4 4 4 4 4 4 4

 

range() Method in For Loop

The range() method in Python creates an immutable sequence of numbers starting with the supplied start integer and ending with the specified finish integer. It’s a built-in function that returns a range object made up of a series of integer integers that we may loop over. We can use a range to make writing a for loop easier (). The range() function must have a fixed stop value, but we can vary the start ing value and the step between integers.

Operators in Python

Operators are constructs defined within programming languages that behave in general like functions but differ syntactically or semantically. Arithmetic, comparison, and logical operations are common elementary examples. An operator is a type of object in computer programming on the command line that can manipulate a value or another operator.