1. BASIC METHODS IN NUMPY Creating Array
Posted: Tue Jul 22, 2025 10:49 am
Hi everyone,
Here's a useful Python script for beginners learning **NumPy array operations**, as covered in Chapter 2 of the ICAI AICITSS Python Module. This script includes examples like 1D arrays, 2D matrices, zero/one arrays, and value ranges — all very helpful in financial data modeling!
You can copy and run this directly in your Python environment:
---
**CA Tip**: You can adapt this logic for real-world CA tasks like:
* Representing monthly trial balances
* Creating GST payment matrices
* Simulating fixed entries like depreciation or standard costs
Here's a useful Python script for beginners learning **NumPy array operations**, as covered in Chapter 2 of the ICAI AICITSS Python Module. This script includes examples like 1D arrays, 2D matrices, zero/one arrays, and value ranges — all very helpful in financial data modeling!
You can copy and run this directly in your Python environment:
Code: Select all
import numpy as np
# 1. Creating a 1D array
arr = np.array([1, 2, 3])
print("1D Array:\n", arr)
Code: Select all
# 2. Creating a 2D array (matrix)
matrix = np.array([[1, 2, 3], [4, 5, 6]])
print("\n2D Matrix:\n", matrix)
Code: Select all
# 3. Creating arrays of zeros
zeros = np.zeros((3, 3))
print("\nZeros Array (3x3):\n", zeros)
Code: Select all
# 4. Creating arrays of ones
ones = np.ones((2, 2))
print("\nOnes Array (2x2):\n", ones)
Code: Select all
# 5. Creating a range of values
rng = np.arange(0, 10, 2) # Start at 0, stop before 10, step by 2
print("\nRange Array (0 to 10 step 2):\n", rng)
* Representing monthly trial balances
* Creating GST payment matrices
* Simulating fixed entries like depreciation or standard costs