Python Program to Print Right Triangle of 1 and 0
In this program, we will print a right triangle pattern of 1s and 0s using Python.
Python Code:
# Python Program to Print Right Triangle of 1 and 0
n = 5
for i in range(1, n + 1):
for j in range(1, i + 1):
print("1", end="")
print()
Output:
1
11
111
1111
11111
By using nested loops, we can print the right triangle of 1s as shown above. Each iteration of the outer loop adds one more “1” to the pattern. This program demonstrates the basics of using loops to create patterns in Python.
Tags:
#shorts #youtubeshorts #shortsvideo