Python Program to Print 0-01-010-0101 Binary Number Pattern
Question: write a program in Python to generate a 0-01-010-0101 binary number pattern up to n lines, where n is given by the user.
Python Source Code: 0-01-010-0101 Pattern
# Program to print 0-01-010-0101
n = int(input("Enter number of lines of pattern: "))
for i in range(1,n+1):
for j in range(1, i+1):
print((j+1)%2, end="")
print()
The output of the above program is:
Enter number of lines of pattern: 12 0 01 010 0101 01010 010101 0101010 01010101 010101010 0101010101 01010101010 010101010101