Friday, February 1, 2019

Identity Matrix

  • Problem Description

    Write a python program to create a NESTED LIST and print the identify matrix (without commas and brackets) 

    Hint:

    1. Input the number of rows and columns of the Square Matrix


    Output:

    Display the identify matrix based on the input from the user
  • CODING ARENA
  • a=int(input())
    for i in range(a):
        for j in range(a):
            if(i==j):
                print("1")
            else:
                print("0")
  • Test Case 1

    Input (stdin)
    3
    
    
    Expected Output
    1
    
    0
    
    0
    
    0
    
    1
    
    0
    
    0
    
    0
    
    1
  • Test Case 2

    Input (stdin)
    2
    
    
    Expected Output
    1
    
    0
    
    0
    
    1

No comments:

Post a Comment