write a program to print the following python pattern(using for loop)
1
0 1
1 0 1
0 1 0 1
Answers
Answered by
5
Answer:
The given program is written in Python 3.
n=int(input("Enter the number of rows: "))
for i in range(n):
for j in range(i+1,-0,-1):
print(j%2,end=" ")
print()
Explanation:
- Line 1: Accepts the number of rows for the pattern.
- Line 2: Start of outer loop. Used for displaying the rows.
- Line 3: Start of inner loop, used for displaying the columns in the pattern.
- Line 4: Print the numbers.
- Line 5: Print a new line after displaying the row.
See the attachment for output.
•••♪
Attachments:
Answered by
22
Good morning dear
and thanks for your help
but will it harm my phone or not please tell me
Similar questions