Right Angle Triangle Program in Python

Right angle triangle program in python. In the python programming language, build a one-side pyramid pattern. The pattern program in python will be printed by this program. A right-angled triangle has one right-angled angle. The foundation of trigonometry is the relationship between the sides and angles of a right triangle.

lines = 5

for i in range(0, lines):

for j in range(0, i + 1):

print("*", end=' ')

print("\r")

Output:

*

* *

* * *

* * * *

* * * * *

Looping Statement in Python

To loop through an iterable object and apply the same operation on each element, Python for loops are often used in data science work. A for loop, for example, allows us to iterate over a list of items, doing the identical operation on each one. The for loop is a Python construct that iterates over a sequence, which can be a list, tuple, array, or string. The init step is the first and only one that must be completed. In this stage, you can declare and initialise any loop control variables.

\r in Python

Conversely, prefixing a special character with “\” turns it into an ordinary character. In Python, the backslash “\” is a special character. It is also called the “escape” character. In Python strings, the backslash “\” is a special character, also called the “escape” character. It is used in representing certain whitespace characters: “\t” is a tab, “\n” is a newline, and “\r” is a carriage return.┬áIt is used in representing certain whitespace characters. “\n” prints a string in a new line, “\t” is a tab, and “\r” is a carriage return.