 Tags IOS SQL HTML C RUBY-ON-RAILS MYSQL ASP.NET DEVELOPMENT RUBY .NET LINUX SQL-SERVER REGEX WINDOWS ALGORITHM ECLIPSE VISUAL-STUDIO STRING SVN PERFORMANCE APACHE-FLEX UNIT-TESTING SECURITY LINQ UNIX MATH EMAIL OOP LANGUAGE-AGNOSTIC VB6 # How to print sub matrix in python?

By : lisaw
Date : October 16 2020, 03:08 PM
will be helpful for those in need Is there any short way in python to print sub matrix of a bigger matrix like this not using for loop? , For lists of lists, you can get your desired result like this: code :
``````>>> [s[1:3] for s in matrix[1:3]]
[[6, 7], [10, 11]]
>>>
>>> [s[2:3] for s in matrix[1:4]]
[, , ]
>>>
``````

## python 2D matrix simple logic works but matrix print logic doesnt show correct matrix

By : Prabhat Tamrakar
Date : March 29 2020, 07:55 AM
I hope this helps you . Must be something really stupid that I am doing but I can't seem to figure out what is going wrong here. I am an intermediate python user. , When you do
code :
``````Xr = [*m]*n
``````
``````m = 2
n = 2
Xr = [*m]*n
print Xr
# [[0, 0], [0, 0]]
Xr = 1
print Xr
# [[1, 0], [1, 0]]
``````

## In Python, given that there is a matrix, how do I print a slice of it?

By : Ravikant
Date : March 29 2020, 07:55 AM
This might help you The return value of as_matrix() is array of arrays. So following code should work:
code :
``````import pandas as pd
matrix = df.as_matrix()
print(matrix) # out put first row.
print(matrix[3:5] # output from 3 row up to 4 row.
``````

## Print all the non-zero element in a 2D matrix in Python

By : Ben Booton
Date : March 29 2020, 07:55 AM

## How to print a matrix using Python

By : Rohit Dixit
Date : March 29 2020, 07:55 AM
wish helps you What you are getting is the correct representation of a matrix. You have created a list that contains 4 lists, each list containing 4 '0's. If you want to print it differently then you have some options, but what you are printing is the representation of the above mentioned data structure.

## the out put is to print out the transpose of the matrix from the matrix you type in, but my code just print out the firs

By : utr
Date : March 29 2020, 07:55 AM
will be helpful for those in need You swap everything twice, so it ends up the same as when you started. Try this, I've commented the line that changes.
code :
``````int ChuyenVi(int A, int n)
{
for(int i=0; i<n; i++)
{
for(int j=0; j<i; j++) // <-- change here
{
DoiGiaTri(A[i][j], A[j][i]);
}
}
XuatMang(A,n);
return 0;
}
`````` 