Numerical Python
Name: Padilla, Erich S.
Section: 2ECE-C
Date Submitted: September 09, 2025
This programming assignment contains programs that solve two different problems:
- Normalization Problem
- Creates a random 5x5 array, normalizes it, and saves it as ".npy"
- Divisible by 3 Problem
- Starts with a 10x10 array of the squares of the first 100 integers, filters elements divisible by 3, and saves them as ".npy" file.
This program first creates a 5x5 array with random elements, which is stored in variable "X". These elements are then normalized using the formula. In Python, the mean and standard deviation can be obtained using .mean()
and .std()
.
X = np.random.random((5, 5))
X_normalized = ((X-X.mean())/X.std())
Finally, with the use of np.save()
the normalized array is stored in an npy
file. This file can later be loaded back into the program using np.load()
, as long as it is in the same directory.
np.save('div_by_3.npy', div_by_3)
np.load('X_normalized.npy')
For the second problem, a 10x10 array containing the squares of the first 100 integers is created. The function np.arange()
ensures that the array contains only the required elements, while np.reshape()
is used to format it into the desired shape.
nums = np.arange(1, 101)
nums_squares = nums**2
A = nums_squares.reshape(10,10)
To filter the array and extract only the elements divisible by 3, the modulus operator %
is applied to check if a number is a multiple of 3.
div_by_3 = A[A % 3 == 0]
Similar to the first problem, the filtered array is saved as an npy
file using np.save
, and it can be reloaded in the program with np.load
.
np.save('div_by_3.npy', div_by_3)
np.load('div_by_3.npy')
This assignment provided practical experience with NumPy for numerical computations and array manipulation. By working on the normalization and divisibility problems, I learned how to create, reshape, and process arrays using common NumPy functions such as arange(), reshape(), mean(), and std(). I also practiced saving and loading data using .npy files with np.save() and np.load(), which is useful for storing preprocessed data. These activities deepened my understanding of how to handle numerical data efficiently in Python. Overall, this assignment strengthened my foundational skills in scientific computing using NumPy, which is essential for more advanced tasks in data analysis and engineering applications.
- v.01
- v.02
- added comments in the python code
- included a conclusion section in the README file