================================================================================
  Question 31: NumPy Matrix Reshaping, Transpose, Aggregation, and Boolean Indexing
================================================================================

FULL QUESTION:
Write a Python program using NumPy to:
1. Create a 1D array of numbers from 1 to 20.
2. Reshape it into a 4x5 matrix.
3. Find the transpose of the matrix.
4. Calculate:
   - Sum of all elements
   - Row-wise sum (axis=1)
   - Column-wise sum (axis=0)
5. Extract all even numbers from the array using Boolean indexing.

SHORT QUESTION:
NumPy program demonstrating 1D array generation, 4x5 reshaping, matrix transpose, axis-wise sums, and boolean indexing.

================================================================================
README & SETUP INSTRUCTIONS:
================================================================================
# Question 31: NumPy Matrix Reshaping, Transpose, Aggregation, and Boolean Indexing

- Prerequisites: Python 3.x, NumPy (pip install numpy).
- Setup: None.
- How to Run: python question_31.py
- Expected Behavior: Creates array 1..20, reshapes to 4x5, computes transpose, element/row/col sums, and filters even elements.

================================================================================
SOURCE CODE FILES:
================================================================================

1. question_31.py
--------------------------------------------------------------------------------
import numpy as np

arr_1d = np.arange(1, 21)
print("1D Array (1 to 20):")
print(arr_1d)
print("-" * 50)

matrix_4x5 = arr_1d.reshape(4, 5)
print("4x5 Matrix:")
print(matrix_4x5)
print("-" * 50)

transpose_matrix = matrix_4x5.T
print("Transposed Matrix (5x4):")
print(transpose_matrix)
print("-" * 50)

total_sum = np.sum(matrix_4x5)
row_sum = np.sum(matrix_4x5, axis=1)
col_sum = np.sum(matrix_4x5, axis=0)

print(f"Total Sum of all elements : {total_sum}")
print(f"Row-wise Sum             : {row_sum}")
print(f"Column-wise Sum          : {col_sum}")
print("-" * 50)

even_numbers = matrix_4x5[matrix_4x5 % 2 == 0]
print("Even numbers (Boolean indexing):")
print(even_numbers)
--------------------------------------------------------------------------------
