Moychay Menghai Gongting and Bada shou pu'er comparison

Matrix Display -Type 1

  • Problem Description

    Write a python program to create a NESTED LIST and form a matrix. 

    Hint:

    1. Input the number of rows and columns for First Matrix

    2. Input the number of rows and columns for Second Matrix

    3. Display the first matrix elements in Matrix format

    4. Display the first matrix elements in Matrix format
  • CODING ARENA
  • a=int(input())
    b=int(input())
    print("Matrix 1")
    for i in range(a):
        n=[]
        for j in range(a):
            x=int(input())
            n.append(x)
        print(n)
    print("Matrix 2")
    for i in range(b):
        n=[]
        for j in range(b):
            x=int(input())
            n.append(x)
        print(n)    
  • Test Case 1

    Input (stdin)
    2
    
    2
    
    10
    
    20
    
    30
    
    40
    
    1
    
    2
    
    3
    
    4
    
    
    Expected Output
    Matrix 1
    
    [10, 20]
    
    [30, 40]
    
    Matrix 2
    
    [1, 2]
    
    [3, 4]
  • Test Case 2

    Input (stdin)
    3
    
    3
    
    1
    
    2
    
    3
    
    4
    
    5
    
    6
    
    7
    
    8
    
    9
    
    10
    
    20
    
    30
    
    40
    
    50
    
    60
    
    70
    
    80
    
    90
    
    
    Expected Output
    Matrix 1
    
    [1, 2, 3]
    
    [4, 5, 6]
    
    [7, 8, 9]
    
    Matrix 2
    
    [10, 20, 30]
    
    [40, 50, 60]
    
    [70, 80, 90]

Comments