Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to Take Matrix input from user in Python

matrix = []
n = int(input("Enter the number of row = "))
for i in range(n):
    row = []
    print("Enter the all values of -", (i+1), "no. row with enter", end='')
    for j in range(n):
        row.append(int(input()))
    matrix.append(row)
print(matrix)
Comment

matrix user input in python

import numpy as np
  
R = int(input("Enter the number of rows:"))
C = int(input("Enter the number of columns:"))
  
  
print("Enter the entries in a single line (separated by space): ")
  
# User input of entries in a 
# single line separated by space
entries = list(map(int, input().split()))
  
# For printing the matrix
matrix = np.array(entries).reshape(R, C)
print(matrix)
Comment

PREVIOUS NEXT
Code Example
Python :: python save input to text file 
Python :: rangoli in python 
Python :: pyqt pylatex 
Python :: python watchgod 
Python :: flask make static directory 
Python :: dice roller python 
Python :: degrees to radians python 
Python :: how to know if the numbers is par in python 
Python :: python search string for word 
Python :: get index pandas condition 
Python :: python gtts 
Python :: dire Bonjour en python 
Python :: python know the number of a loop 
Python :: internet explorer selenium 
Python :: print all alphabets from a to z in python 
Python :: python- number of row in a dataframe 
Python :: python random choice in list 
Python :: remove minutes and seconds from datetime python 
Python :: python nmap 
Python :: plot horizontal line in python 
Python :: how to find location using latitude and longitude in python dataframe 
Python :: loop rought rows in pands 
Python :: plot bounds python 
Python :: multiple input in python 
Python :: shift coordinate in python 
Python :: youtube-dl python download to specific folder 
Python :: scrapy user agent 
Python :: python list methods 
Python :: pandas change every row to df 
Python :: python des 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =