Python: Read a matrix from console and print the sum for each column
Sum Matrix Columns from Console Input
Write a Python program to read a matrix from the console and print the sum for each column. As input from the user, accept matrix rows, columns, and elements separated by a space (each row).
Visual Presentation:

Sample Solution:
Python Code:
Sample Output:
Input rows: 2 Input columns: 2 Input number of elements in a row (1, 2, 3): 1 2 3 4 sum for each column: 4 6
Flowchart:

For more Practice: Solve these Related Problems:
- Write a Python program to sum all rows in a matrix.
- Write a Python program to compute the sum of matrix diagonals.
- Write a Python program to find the largest sum among matrix columns.
- Write a Python program to calculate row-wise and column-wise sums of a matrix.
Go to:
Previous: Write a Python program to create a 3X3 grid with numbers.
Next: Write a Python program to read a square matrix from console and print the sum of matrix primary diagonal. Accept the size of the square matrix and elements for each column separated with a space (for every row) as input from the user.
Python Code Editor:
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.