How To | Print Screw Matrix | Python Program

Print a screw matrix in python:

Tips:

1.Size of square matrix asked from user.
2. Nested loop is required.
3.if and else used.  

Code:

n=int(input("Enter the size [column][row]: "))

for i in range(n):

    for j in range(n):

        if(i==j):

            print("1",end=" ")

        else:

            print("0",end=" ")

    print()

Output:

 


Comments

  1. Brilliant approach, very good ��.
    Why the output part is so small?
    I had to zoom the page to see it clearly.

    ReplyDelete

Post a Comment

Give your feedback!
DO NOT SPAM !!
NO THIRD PARTY PROMOTIONAL LINK !!!! (else comment will be deleted.)

Popular posts from this blog

TOP 10 PROGRAMMING LANGAUAGES COMMING 2021 | ARTICLE

Write a C-program to swap two number:

Print Fibonacci Series using Recursion | C program :